首页 > 代码库 > linq高级查询
linq高级查询
Linq高级查
开头: Repeater1.DataSource = con.Users.Where(r => r.NickName.StartsWith("值"));
结尾: Repeater1.DataSource = con.Users. Where( r => r.NickName.EndsWith("值"));
模糊查(包含):Repeater1.DataSource = con.Users.Where(r => r.NickName.Contains("值"));
个数: ulist.Count + "</br>");
最大值: ulist.Max(r => Convert.ToDecimal(r.PassWord)) + "</br>");
最小值: ulist.Min(r => Convert.ToDecimal(r.PassWord)) + "</br>");
平均值: ulist.Average(r => Convert.ToDecimal(r.PassWord)) + "</br>");
求和: ulist.Sum(r => Convert.ToDecimal(r.PassWord)) + "</br>");
排序
升序: ulist.OrderBy ( r =>r.Ids )
降序:ulist.OrderByDescending( r =>r.Ids )
分页:ulist . Skip( 3 )//跳过几条 . Take( 3 ) //取几条
集合的交集;list <users> ulist = list1.Intersect( list2).Intersect( list3);//取多个集合交集 有多少个集合 写多少个Intersect
linq高级查询