使实体框架不区分大小写

发布于 2024-09-06 03:44:48 字数 250 浏览 0 评论 0原文

是否可以设置实体框架字符串比较默认不区分大小写?

如果我用

string.StartsWith("stringToCompare", StringComparison.CurrentCultureIgnoreCase)

它就可以了。但当我需要使用

string.Contains("strigToCompare")

它时,它不会过载。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哀由 2024-09-13 03:44:49

您可以简单地将两个字段的大小写更改为大写:

String stringToCompare = "Some String";

string.ToUpper().Contains(stringToCompare.ToUpper())

这将通过将所有大小写转换为大写来使搜索不区分大小写。当然,ToLower() 也可以工作。

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. Of course, ToLower() would work as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文