aamankhaan
aamankhaan

Reputation: 491

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

Upvotes: 0

Views: 224

Answers (1)

Aqeel
Aqeel

Reputation: 689

try this one

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

Upvotes: 2

Related Questions