摘要:
list取得分页数据:tempReturn.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList() 阅读全文
文章分类 - Linq
linq 左连接,右连接,内连接,三表左连接
2022-03-11 21:13 by idea555, 242 阅读, 收藏, 编辑
摘要:
左连接List<Employees> emp = new List<Employees>() { new Employees {id = 1,depid = 1,name = "小李" }, new Employees {id = 2,depid = 2,name = "小张" }, new Emp 阅读全文
LINQ系列:LINQ to DataSet的DataTable操作
2022-03-11 18:43 by idea555, 86 阅读, 收藏, 编辑
摘要:
LINQ to DataSet需要使用System.Core.dll、System.Data.dll和System.Data.DataSetExtensions.dll,在项目中添加引用System.Data和System.Data.DataSetExtensions。 1. DataTable读取 阅读全文
Linq Group By 多个字段
2022-03-04 16:05 by idea555, 309 阅读, 收藏, 编辑
摘要:
var counts = dal.QueryStatisticsCount(condition); var result = from p in counts group p by new { AuctionName = p.AuctionName, StatusName = p.StatusNam 阅读全文
Linq之GroupBy用法
2022-03-04 16:02 by idea555, 415 阅读, 收藏, 编辑
摘要:
1.简单形式: var q = from p in db.Products group p by p.CategoryID into g select g; 语句描述:Linq使用Group By按CategoryID划分产品。 说明:from p in db.Products 表示从表中将产品对象 阅读全文
linq 左连接
2022-03-03 15:28 by idea555, 147 阅读, 收藏, 编辑
摘要:
直接上代码了: 1.下部分代码是两个表左连接查询: var list = from a in db.tableInfos1 join b in db.tableInfos2 on a.ID equals b.Id into bb from bbdata in bb.DefaultIfEmpty() 阅读全文
List中对比Contains, Exists, Any之间的优缺点
2020-06-10 19:54 by idea555, 291 阅读, 收藏, 编辑
摘要:
在List<T>中,Contains, Exists, Any都可以实现判断元素是否存在。 先上结果。性能方面:Contains 优于 Exists 优于 Any 以下为测试代码 public static void Contains_Exists_Any_Test(int num) { List< 阅读全文
Linq 排序
2020-06-10 15:22 by idea555, 72 阅读, 收藏, 编辑
摘要:
List<Product> productList = new List<Product> { new Product {Id = 1,Name="xiong",Order1 = 1,Order2 = 1 }, new Product {Id = 1,Name="xiong",Order1 = 2, 阅读全文
如何很好的使用Linq的Distinct方法
2020-06-08 19:24 by idea555, 95 阅读, 收藏, 编辑
摘要:
Person1: Id=1, Name="Test1" Person2: Id=1, Name="Test1" Person3: Id=2, Name="Test2" 以上list如果直接使用distinct方法进行过滤,仍然返回3条数据,而需要的结果是2条数据。下面给出解这个问题的方法: 方法1: 阅读全文
FindAll和Linq where的区别
2020-06-04 20:23 by idea555, 501 阅读, 收藏, 编辑
摘要:
我们在集合查询时经常用到FindAll和where筛选集合。二者实现的功能都是一样的. 1.FindAll是List<T>类型中的一个方法,而不像where是一个Linq表达式的扩展方法。我们知道linq表达式可以基于所有继承IEnumerable的集合上使用,而FindAll只能运用于List<T 阅读全文