c# - linq 不区分大小写(没有 toUpper 或 toLower)

标签 c# linq

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。可能吗?

最佳答案

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

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

关于c# - linq 不区分大小写(没有 toUpper 或 toLower),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5312585/

相关文章:

c# - 为什么我在此代码中收到 "You have an error in your SQL syntax"错误?

.net - 如何在 LINQ to SQL 中编写此 T-SQL?

c# - 使用 let 变量和子查询重构 LINQ to Entities 查询

c# - 使用LINQ查询多个表,将结果抓取到字典

c# - 从wmi获取每个进程的Cpu使用率

c# - 有没有办法在运行时设置#define 的值?

c# - 如何使用其应用程序打开文件(该文件不存在于网络服务器中)?

c# - 结构图 3 中 HybridHttpOrThreadLocalScoped 的等价物是什么?

c# - 选择语句执行 "for each"操作,然后返回自身

c# - 使用 linq 选择符合我的条件的对象