开发者

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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜