How to use LINQ Distinct() with multiple fields

前端 未结 9 1367
借酒劲吻你
借酒劲吻你 2020-11-30 01:32

I have the following EF class derived from a database (simplified)

class Product
{ 
     public string ProductId;
     public string Product         


        
9条回答
  •  孤独总比滥情好
    2020-11-30 02:24

    The Distinct() guarantees that there are no duplicates pair (CategoryId, CategoryName).

    - exactly that

    Anonymous types 'magically' implement Equals and GetHashcode

    I assume another error somewhere. Case sensitivity? Mutable classes? Non-comparable fields?

提交回复
热议问题