Home > database >  Entity Framework Core 6.0.8 WHERE clause for dynamic query issues
Entity Framework Core 6.0.8 WHERE clause for dynamic query issues

Time:12-01

I used EF 6.0.8 in my project

Here, you will see the example of my code

var searchCriteria = CreateSearchString<T>(model);
if (!string.IsNullOrEmpty(searchCriteria))
{
    result = !string.IsNullOrEmpty(searchCriteria)
        ? enumerable.AsQueryable().Where(searchCriteria, model.Search.Value.ToLower())
        : enumerable.AsQueryable();
}

"( it.Parent1FirstName != null && it.Parent1FirstName.ToString().ToLower().Contains("Parent1"))"

I have created dynamic query to filter records based on COLUMN property. see below image.

enter image description here

Query applied to my Enumerable data source BUT it not filtering my data. see below image.

enter image description here

DATABASE SOURCE

enter image description here

CodePudding user response:

Resolved, It was my bad.

I was comparing .toLower() case only for value not for properties

It's working fine now.

  • Related