Linq to object - Select Distinct
Posted
by Ben
on Stack Overflow
See other posts from Stack Overflow
or by Ben
Published on 2010-03-18T14:26:23Z
Indexed on
2010/03/18
14:31 UTC
Read the original article
Hit count: 382
Hi,
I can't quite figure out why this Linq Statement isn't working as i would expect:
Dim distinctSurchargesList = (From thisparent As Parent In ThisParentCollection _
From thisChild As Child In thisparent.theseChildren _
Select New With {.childId = thischild.Id}).Distinct()
I would assume that this would create a new collection of anonymous types, that would be distinct. Instead it creates a collection the size of the "ThisParentCollection" with duplicate "MyAnonymousType" in it (duplicate id's).
Can anyone tell me where im going wrong?
Thanks
© Stack Overflow or respective owner