0

I want to use linq to sort a resultset. The resultset should contain all items which has it's code also in the given array. To make this a bit clearer, in sql this should be:

select * from tblCodes where CodeSort in (0, 2, 3, 5, 6)

Now I want to do the same thing in LINQ but I can't seem to pull it off.. I've tried Contains, but that didn't give me the correct result (or I might have been using it wrong). I'm writing my code in VB.

Thanks for your help :)

Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
Jens
  • 3,249
  • 2
  • 25
  • 42

1 Answers1

3

Check this

Dim ids = {1, 2, 3}

Dim query = From item In context.items Where ids.Contains(item.id)item

Linq to SQL in and not in

Community
  • 1
  • 1
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
  • Okay, I was being silly. Seems it DID work, I was just checking the wrong values. Thanks for pointing out I was right anyways ;) – Jens Sep 09 '10 at 08:41