Dynamic Linq Querystring not working with mixed operators along with contains

.net c# dynamic-linq linq linq-to-sql

Question

I have used Dynamic Linq in my application and unfortunately it's not working. Here is my sample code.

List<string> contains = new List<string>() { "Poland", "Ecuador" };
List<object> array = new List<object>();
array.Add("Austria");
array.Add("Eritrea");
array.Add(contains);

//this works
var data0 = Contact.GetContactsList().AsQueryable().Where("@0.Contains(outerIt.Country)", array);

//this does not work
var data = Contact.GetContactsList().AsQueryable().Where("Country.Equals(@0) OR it.Country.Equals(@1) OR @3.Contains(outerIt.Country)", array.ToArray());

I have list of contacts related with countries. You can see that I have used mixed operators i.e equals and contains. If contains is used separately then it works which is correct. I tried to do new thing here, using both Equals and Contains operators is same query string. I have attached am image describing output or data0 and error while processing to get data

enter image description here

Thank You.

1
0
1/9/2017 7:53:38 AM

Popular Answer

I made a silly mistake there. The code is working fine but I gave wrong index there. Index 3 should be replaced with 2. :P enter image description here

The result is attached.

0
1/9/2017 8:51:05 AM


Related Questions





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