How to get a distinct list from a List of objects?

后端 未结 10 1229
滥情空心
滥情空心 2020-12-24 04:59

I have a List someList.

class MyClass
{
    public int Prop1...
    public int Prop2...
    public int Prop3...
}
10条回答
  •  一向
    一向 (楼主)
    2020-12-24 05:34

    Since the introduction of value tuples, if you want a LINQ equivalent to SQL's DISTINCT

    items.GroupBy(item => (item.prop1, item.prop2, ...)).Select(group => group.First())
    

提交回复
热议问题