LINQ, where in (Value1, Value2, Value3.) equivalent Statement.
This Code Segment Help you to write Where in (x1, x2 ) equivalent statement in LINQ. The "IN" clause is built in linq via the .Contains() method
While Working, I have come across scenario to write Linq equivalent for following query.
SELECT ID,Name, ContactTitle, Address, City, Region, PostalCode,
Country, Phone FROM Author WHERE Country IN ('UK', 'USA', 'Australia')
Please see the Equivalent statement in LINQ below... Query syntax
string[] countries = new string[] { "UK", "USA", "Australia" };
var Author = from c in context.Author s
where countries.Contains(c.Country)
select c; Lambda expression
string[] countries = new string[] { "UK", "USA", "Australia" };
var Author = Author.Where(c => countries.Contains(c.Country));
I have a query.What does context.Author s refer to?