EF lambda表达式多条件查询
lambda表达式多条件查询
并且,与或者:&&与||
clist = clist.Where(r => r.Price > 50 && r.Price < 60 || r.Price < 30).ToList();
包含:containsList<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();