简体   繁体   中英

Entity Framework Core 6.0.8 WHERE clause for dynamic query issues

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.

在此处输入图像描述

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

在此处输入图像描述

DATABASE SOURCE

在此处输入图像描述

Resolved, It was my bad.

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

It's working fine now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM