LINQ区分大小写(不TOUPPER或TOLOWER) [英] linq case insensitive (without toUpper or toLower)

查看:281
本文介绍了LINQ区分大小写(不TOUPPER或TOLOWER)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public Articles GetByName(string name, Categories category, Companies company)
        {
    var query = from article in session.Linq<Articles>()
                            where article.Name == name &&
                                article.Category == category &&
                                article.Company == company
                            select article;

                return query.FirstOrDefault();
}



如何查询不区分大小写。我可以使用TOLOWER或TOUPPER,但我想用OrdinalIgnoreCase。这可能吗?

how can query be case insensitive. I can use toLower or toUpper but i want with OrdinalIgnoreCase. Is it possible?

推荐答案

使用 String.Equals 配合适当的参数使其不区分大小写

Use String.Equals with the appropriate parameters to make it case insensitive

mySource.Where(s => String.Equals(s, "Foo", StringComparison.CurrentCultureIgnoreCase));

这篇关于LINQ区分大小写(不TOUPPER或TOLOWER)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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