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

后端 未结 12 2064
别那么骄傲
别那么骄傲 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 18:59

        var keys = new[] {
            new {Country=…, City=…, Address=…},
            …
        }    
        var result = from loc in Location
                     where keys.Any(k=>k.Country == loc.Country 
    && k.City == loc.City 
    && k.Address == loc.Address) 
    select loc
    

    Give this a try.

提交回复
热议问题