在Linq-to-objects上使用Contains和Dynamic Linq时,搜索区分大小写。我希望能够搜索不区分大小写(如Linq- to - SQL,因为SQL server默认这样做)。
类似于:
this.someQuery = this.someQuery.Where(field + ".Contains(@0, true)", strValue);其中true的意思是:caseinsensitive = true,就像System.String.Contains提供的扩展之一。尽管在默认情况下,我不能在dynamic Linq中使用System.String的扩展。
发布于 2011-11-22 20:58:07
你能把比较的两边都用.ToLower()吗?如下所示:
this.someQuery = this.someQuery.Where(field.ToLower().Contains(strValue.ToLower()));还是我误解了你要找的东西?
发布于 2021-04-16 03:17:08
使用"toLower“时,请确保包含() "ToLower()”
发布于 2021-11-24 10:30:07
如果您想使用占位符,那么您的代码应该如下所示
this.someQuery = this.someQuery.Where("field" + ".ToLower().Contains(@0.ToLower())", strValue);https://stackoverflow.com/questions/8227072
复制相似问题