[英]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. 我创建了一个SQL Server存储过程,我绑定到我的类属性,如下所示。
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 现在我想只显示包含
bil
的CustomerName
- 因为我使用了这个查询,但我不知道它为什么总是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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.