views:

42

answers:

1

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 :)

+3  A: 

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

Pranay Rana
Okay, I was being silly. Seems it DID work, I was just checking the wrong values. Thanks for pointing out I was right anyways ;)
J. Vermeire