陪你听风

EF lambda表达式多条件查询

电脑版发表于:2020/5/20 13:44


lambda表达式多条件查询

并且,与或者:&&||

clist = clist.Where(r => r.Price > 50 && r.Price < 60 || r.Price < 30).ToList();


包含:contains

 List<car> clist= new cardata().SelectAll().Where(r => r.Name.Contains(TextBox1.Text)).ToList();

 等于:==

 clist = clist.Where(r => r.Price==40).ToList();

  clist = clist.Where(r => r.Price.Equals(40)).ToList();

 以。。开始、以。。结束

 List<users> ulist = con.users.Where(r => r.username.StartsWith("s")).ToList();

            List<users> ulsit = con.users.Where(r => r.username.EndsWith("t")).ToList();

最大值、最小值、平均值、求和

 int s = con.users.Max(r=>r.ids);

            int t = con.users.Min(r=>r.ids);

            double h = con.users.Average(r => r.ids);

            int d = con.users.Sum(r => r.ids);

求交集

            List<users> ulist1 = new List<users>();

            List<users> ulist2 = new List<users>();

            List<users> ulist3 = new List<users>();

            List<users> ulist = ulist1.Intersect(ulist2).Intersect(ulist3).ToList();    

顺序、倒序

            List<users> ulist = con.users.OrderBy(r => r.ids).ToList();

            List<users> ulist1 = con.users.OrderByDescending(r => r.ids).ToList();




关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢