score:-1

the count() method takes a predicate, so you would do something like this:

if(myobjectlist.count(x => x.order == 1) >= 2)
{
    // do something
}

score:1

not a pure linq-to-objects-solution, but how about:

var orderslist = new list<order>(myobjectlist.select(obj => obj.order);
bool allunique = orderslist.count == new hashset<order>(orderslist).count;

one would have to test performance of all the approaches presented here. i'd be careful, otherwise you end up quickly with some slow o(n²) look-ups.

score:1

what about distinct?

bool allunique = orderslist.count == orderslist.select(o => o.order).distinct().count()

score:2

bool hasduplicates = myobjectlist.count >
    new hashset<int>(myobjectlist.select(x => x.order)).count;

score:11

first groupby myobject.order and then determine if any of the groups have more than one member:

bool b = myobjectlist.groupby(x => x.order)
                     .any(g => g.count() > 1);
// b is true is there are at least two objects with the same order
// b is false otherwise

Related Query