System.Linq.Dynamic: How to declare an array for .Contains?

c# dynamic-linq entity-framework-6

Question

I am trying to do a simple SQL where field in (2,3,4) with Dynamic Linq. kahanu's rehosted Microsoft Dynamic Linq Library has a .Contains() that you can use in Linq like this:

var results = myTable.Where("@0.Contains(outerIt.abc)", new int[] { 2, 3, 4});

How would you remove the array parameter and specify the array in the string? Something like this but actually works?

var results = myTable.Where("[2,3,4].Contains(outerIt.abc)");

I looked through his Microsoft documentation but it doesn't explain the .Contains() All the documentation I've found on the Internet only refers to creating an array and passing it as a parameter like the first example above, but I found nothing on how to do the second example with just strings.

1
0
1/26/2018 5:38:44 AM

Popular Answer

When using System.Linq.Dynamic.Core you can don something like:

var intList = new[] { 2, 3, 4 };
var results = myTable.Where("@0.Contains(outerIt.abc)", intList);
0
2/5/2018 9:22:36 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow