LINQ to Entities - where..in clause with multiple columns

后端 未结 12 2060
别那么骄傲
别那么骄傲 2020-12-05 18:23

I\'m trying to query data of the form with LINQ-to-EF:

class Location {
    string Country;
    string City;
    string Address;
    …
}

by

12条回答
  •  生来不讨喜
    2020-12-05 19:14

    var result = from loc in Location
                 where keys.Contains(new {
                     Country=l.Country, 
                     City=l.City, 
                     Address=l.Address
                 }
    

    would need to be:

    var result = from loc in Location
                 where keys.Contains(new {
                     Country=loc.Country, 
                     City=loc.City, 
                     Address=loc.Address
                 }
                 select loc;
    

提交回复
热议问题