使用linq iqueryable时如何进行不区分大小写的搜索 [英] How do I do a case insensitive search when using linq iqueryable

查看:92
本文介绍了使用linq iqueryable时如何进行不区分大小写的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我遇到了问题,我正在建立一个搜索屏幕,它会从Web服务调用以及我的实体框架数据库中返回一个列表。



我根据用户想搜索的内容使用过滤器构建了我的linq查询

问题是结果只有在查询的大小写时才返回匹配数据库中存储的内容。



我尝试过:



这是我在尝试搜索时正在运行的查询



var deleg = ExpressionBuilder.GetExpression< customer>(filters).Compile();

IQueryable< customer> portalResults = this.DbContext.Customers.Where(deleg).AsQueryable();

解决方案

尝试使用Tolower()参数。 Customers.Tolower()。其中​​(delete.Tolower())

Hi
I am having an issue, i am building a search screen which returns a list from a web service call as well as my Entity Framework Database.

I have built a my linq query using filters based on what user would like to search for
the issue is results are only returned if the casing on the query matches what is stored in the database.

What I have tried:

This is the query i am currently running when trying to search

var deleg = ExpressionBuilder.GetExpression<customer>(filters).Compile();
IQueryable<customer> portalResults = this.DbContext.Customers.Where(deleg).AsQueryable();

解决方案

Try using the Tolower() argument. Customers.Tolower().Where(delete.Tolower())


这篇关于使用linq iqueryable时如何进行不区分大小写的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆