IQueryable<MyModel> myList = GetListMyModel().AsQueryable();
myList = myList.Where(m => m.Name.Contains('John'));
我想用Name ='John'或'john'或'JOHN'(不区分大小写)返回所有内容
答案 0 :(得分:0)
您可以将所有内容转换为小写过滤器,例如
IQueryable<MyModel> myList = GetListMyModel().AsQueryable();
myList = myList.Where(m => m.Name.ToLower().Contains("John".ToLower());
或使用
IQueryable<MyModel> myList = GetListMyModel().AsQueryable();
myList = myList.Where(m => m.Name.IndexOf("John",StringComparison.OrdinalIgnoreCase) != -1);
答案 1 :(得分:0)
myList = myList.Where(m => m.Name.ToLowerInvariant().Contains("John".ToLowerInvariant()));