2

Tried this:

.Where("MyColumnID.Contains(@0)", myArray)

But what i got was:

No applicable method 'Contains' exists in type 'Int32'

Any other ways? Something like SqlMethods.Like, but in DynamicLinq?

  • what type and value of `myArray`? – Grundy Feb 14 '14 at 06:40
  • possible duplicate [How to Type Cast dynamically to string while using Contains in Dynamic LINQ?](http://stackoverflow.com/questions/19315762/how-to-type-cast-dynamically-to-string-while-using-contains-in-dynamic-linq]) – Grundy Feb 14 '14 at 06:46

2 Answers2

2

The Contains() operator works the other way around: It's the array which contains the number, thus it should read as follows:

"@0.Contains(MyColumnID)"

I am however, not sure if this is even possible within DynamicLinq. This other SO question deals with the same problem:

Query data using "Contains" keyword in Dynamic Linq in C#

It suggests the following should work:

int[] CandidateIdsArray = new int[]{4, 78, 101}
var dynamicLinqQuery = 
    Candidates.Where("@0.Contains(CandidateId)", CandidateIdsArray);
Community
  • 1
  • 1
w5l
  • 5,341
  • 1
  • 25
  • 43
0

Try this

.Where("@0.Contains(MyColumnID)", myArray)
Fatih
  • 945
  • 15
  • 26