[英]Make Entity Framework be case-insensitive
Is it possible to set entity framework string comparison case insensitive by default? 默认情况下是否可以设置实体框架字符串比较不区分大小写?
If I use 如果我使用
string.StartsWith("stringToCompare", StringComparison.CurrentCultureIgnoreCase)
it works. 有用。 But when I need to use
但是当我需要使用时
string.Contains("strigToCompare")
it doesn't have an overload. 它没有过载。
You can simply change the case of both fields to Upper Case: 您只需将两个字段的大小写更改为大写:
String stringToCompare = "Some String";
string.ToUpper().Contains(stringToCompare.ToUpper())
This will make the search case-insensitive by converting all case to upper. 这将通过将所有case转换为upper来使搜索不区分大小写。 Of course, ToLower() would work as well.
当然,ToLower()也可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.