VB .Net LINQ query to determine whether more than one element has the same value for a property?
Posted
by
Alex Hope O'Connor
on Stack Overflow
See other posts from Stack Overflow
or by Alex Hope O'Connor
Published on 2011-06-28T05:47:38Z
Indexed on
2011/06/28
8:22 UTC
Read the original article
Hit count: 312
I am trying to write a LINQ query which will return true if there are multiple objects which have a property with the same value.
Here is what I have come up with so far:
Formatters.Where(Function(f As DataModel.Formatter) _
Formatters.Select(Function(f2 As DataModel.Formatter) f2.Name.ToLower()).Contains(f.Name.ToLower())).Count > 1
However the above always returns true as long as their are more then 1 elements in the list, can someone please give me a hand with this?
Thanks, Alex.
© Stack Overflow or respective owner