just trying to get hold on EF. when we work with sql then we often write multiple value inside in clause
Select * from customer
Where countryCode in ('gb','us','fr')
i was searching how to write the same query with EF and LINQ. i found these code.
var countries= new[] {
new {Country=…, City=…, Address=…},
…
}
approach 1
------------
var result = locations.Where(l => keys.Any(k =>
k.Country == l.Country &&
k.City == l.City &&
k.Address == l.Address));
approach 2
------------
var result = from loc in Location
where keys.Contains(new {
Country=loc.Country,
City=loc.City,
Address=loc.Address
}
select loc;
tell me how to translate below sql query to EF without using multiple contains keyword
Select * from customer
Where countryCode in ('gb','us','fr')