Reputation: 9926
I wrote some query - and i want to be sure that each item in the retList will appear once. The query get all the names that are same as property 'Name' in the collection 'NamesItems' and return at the a collection ( list ) of the name and the picture .
I want to be sure that each name that will appear in the retList will appear once.
How can i do it ?
List<NameVIewItem> retList = null;
IEnumerable<ItemT> u = NamesItems.Where( x => x.Name == Name );
retList = ( from t in ItemsCollection
join o1 in u on t.Key equals o1.Name2
select new NameViewITem ( o1.Key, t.Picture ), o1.Name )).ToList();
Upvotes: 0
Views: 67
Reputation: 17327
If one Name can have multiple Pictures, you will need to put a group by clause in there, then do something like take the first picture
Upvotes: 1
Reputation: 106906
You can use the LINQ Distinct
operator to remove duplicates.
Upvotes: 3