Entity Framework - case insensitive Contains?

后端 未结 3 1680
离开以前
离开以前 2021-01-03 17:39

I want a solution to this problem that does not involve ToUpper or ToLower, as I use in the code below;

var upper = term.ToUpper();
using (var db = this.Data         


        
3条回答
  •  既然无缘
    2021-01-03 18:16

    Just add .ToLower() from upper

     using (var db = this.DataContext)
                {
                    return db.Counties
                           .Where(x => x
                           .CountyName.ToLower()
                           .Contains(upper.ToLower())).ToList();
                }
    

提交回复
热议问题