Hell all!
I tried all known variations to filter with Contains
, but so far no luck.
METHOD #1
ret = ret.Where("CaseID.Contains(@0)", {15, 16, 17})
Gets the following error:
System.Linq.Dynamic.ParseException: 'No applicable method 'Contains' exists in type 'Int32?''
METHOD #2
ret.Where("@0.Contains(outerIt.CaseID)", {15, 16, 17})
Bring the following error:
System.Linq.Dynamic.ParseException: 'No 'it' is in scope'
So, how can i filter by a list or array?
I'm using the latest System.Linq.Dynamic library in nuget 1.0.7
the following will work, but you must to ensure that the CaseID
and the array values have the same Type.
ret.Where("@0.Any(outerIt.CaseID=it)", array)
Not quite sure if I understand your question right. But do you mean something like this? This is solved with a Lambda-Expression.
var listA = new[] {1, 2, 3, 5, 8};
var listB = new[] {1, 3, 5, 7, 11};
var res = listA.Where(itemA => listB.Contains(itemA));
// res = {1,3,5}