此代码区分大小写,如何使其不区分大小写?
public IQueryable<FACILITY_ITEM> GetFacilityItemRootByDescription(string description) { return this.ObjectContext.FACILITY_ITEM.Where(fi => fi.DESCRIPTION.Contains(description)); }
假设我们在这里使用字符串,这是另一个使用的“优雅”解决方案IndexOf()。
IndexOf()
public IQueryable<FACILITY_ITEM> GetFacilityItemRootByDescription(string description) { return this.ObjectContext.FACILITY_ITEM .Where(fi => fi.DESCRIPTION .IndexOf(description, StringComparison.OrdinalIgnoreCase) != -1); }