1

In SQL, you could write a query such as:

SELECT NAME, QUOTA, SALES FROM SALESREPS
WHERE REP_OFFICE IN (11, 13, 52);

How would can I construct a IN set operation within LINQ?

Susan
  • 1,752
  • 8
  • 45
  • 67
  • [http://stackoverflow.com/questions/857973/linq-to-entities-sql-in-clause][1] Check this link to find the answer to your question. –  Jul 26 '11 at 13:33
  • You might want to take a look at this link: [101 LINQ Samples](http://msdn.microsoft.com/en-us/vcsharp/aa336746) Should answer this question and any others you run into. – Chris Jul 26 '11 at 13:35

2 Answers2

3

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;
Anton Gogolev
  • 110,157
  • 37
  • 194
  • 282
0
int[] nums = new { 11, 13, 52 };
IEnumerable<SalesRep> salesReps = 
    MyEntities.SalesReps.Where(s => nums.Contains(s.Rep_Office));
Chris Snowden
  • 4,898
  • 1
  • 24
  • 34