Linq to entites and contains method

R

RBScheer

Hi.

I am trying to simulate the IN operator in Linq to entites using a
List of integers, like below:

Dim lstFound As IList(Of Entities.Local) = Nothing

Dim ls As New List(Of Integer)
ls.Add(21)
ls.Add(38)

lstFound = (From a In context.Local Where a.Area = 1 And
ls.Contains(a.LocalCode)).ToList

When I run this code, I receive the following error:

"LINQ to Entities does not recognize the method 'Boolean
Contains(Int32)' method, and this method cannot be translated into a
store expression."

Can you help me to see what is wrong here or on how to do a correct IN
using integers?

Regards,
Robert Scheer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top