简体   繁体   中英

Linq query for using LIKE operator doesn't work properly

I have created a SQL Server stored procedure which I have bound to my class property like below.

objSearchCustomerCDTO = DbContext.ExecuteStoreQuery<SearchCustomerCDTO>("exec GetSearchCustomerDetails").AsQueryable().ToList();

Please note that I have simply used the stored procedure to bind to my properties

For example : my class have below property

public string CustomerName {get;set;}

and stored procedure returns

Select c.CustomerName as CustomerName from Customer

Now I want to display only the CustomerName containing bil - for that I have used this query, but I don't know why it is always null

var query = objSearchCustomerCDTO
            .Where(c => c.CustomerName.Contains("bil")).ToList();

Please let me know what I am doing wrong in the above query.

Thanks

try this one

var query = objSearchCustomerCDTO
            .Where(c => c.CustomerName.ToLower().Contains("bil")).ToList();

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