实体框架和不区分大小写的字符串搜索 [英] Entity Framework and Case Insensitive String Search

查看:160
本文介绍了实体框架和不区分大小写的字符串搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实体框架实体,其字符串属性名为Description。

搜索描述包含字符串的所有实体简单如下:



u $; tains tains tains tains tains;;;;;;;;;;;;;;;;;;;;;;;;

但是我想支持不区分大小写的搜索?

解决方案

如果您正在使用 Linq来提出搜索是由sql服务器完成的,所以如果搜索区分大小写或不依赖于服务器设置。


I have a Entity Framework entity with a string Property named Description.
Searching for all entities where the Description contains a string is as simple as:

var res = from u ctx.Users where u.Description.contains(str) select u;

But suppose I want to support case insensitive search?

解决方案

If you're using Linq to enties the search is done by the sql server so if the search is case sensitive or not depends on server settings.

这篇关于实体框架和不区分大小写的字符串搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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