LINQ to Entities Qyery Syntax: "IN" set operations
In SQL, you could write a query such as:
SELECT NAME, QUOTA, SALES FROM SALESREPS
WH开发者_如何学JAVAERE REP_OFFICE IN (11, 13, 52);
How would can I construct a IN set operation within LINQ?
I assume we're talking LINQ to Objects here:
var x = from s in SalesReps
where new[] { 11, 13, 52 }.Contains(s.RepOffice)
select s;
int[] nums = new { 11, 13, 52 };
IEnumerable<SalesRep> salesReps =
MyEntities.SalesReps.Where(s => nums.Contains(s.Rep_Office));
精彩评论