How can I utilize System.Linq.Dynamic for the LIKE operation?

asp.net c# dynamic-linq linq

Question

Can somebody explain to me how to utilize the LIKE operator with the System.Linq.Dynamic?

I must include more than one.LIKE my dynamic what question expression

/*
var query =
db.Customers.
Where("CityName Like @0 or CityName Like @1", "London", "USA")
*/
var query =
db.Customers.
Where("CityName Like @0 or CityName Like @1%", "London", "USA")

many thanks

1
13
8/22/2019 1:49:26 AM

Accepted Answer

Simply using "CityName.Contains(@1)" may work since it invokes a method on an accessible type and converts to the correct lambda.

a phrase like:

var query =
db.Customers.
Where("CityName.Contains(@0) or CityName.Contains(@1)", "London", "USA")

It creates the LIKE operator, as I just tried it with the example app that is included with the dynamic library.

26
1/5/2011 2:26:46 AM

Popular Answer

As a result, theLIKE operator on fields of integers:

.Where(searchField + ".ToString().Contains(@0)", searchString);


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