posts - 609,  comments - 13,  views - 64万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

随笔分类 -  Linq

.net使用PLinq并行查询提升查询效率,List.AsParallel(),ForAll()替换Foreach
摘要:参考:https://docs.microsoft.com/zh-cn/dotnet/standard/parallel-programming/introduction-to-plinq var source = Enumerable.Range(1, 10000); // Opt in to P 阅读全文
posted @ 2022-08-05 16:21 邢帅杰 阅读(253) 评论(0) 推荐(0) 编辑
linq join用法,左连接
摘要:单条件: var query = from person in people join pet in pets on person equals pet.Owner select new { OwnerName = person.FirstName, PetName = pet.Name }; 多条 阅读全文
posted @ 2018-08-31 15:29 邢帅杰 阅读(232) 评论(0) 推荐(0) 编辑
linq to sql语句中转换数据类型和日期操作
摘要:System.Data.Entity.SqlServer.SqlFunctions.StringConvertSystem.Data.Entity.DbFunctions//ProDate 大于等于 fromDate 并且 小于等于 toDatedb.Products.Where(x => x.Pr 阅读全文
posted @ 2018-07-24 14:40 邢帅杰 阅读(451) 评论(0) 推荐(0) 编辑
Linq使用group by
摘要:代码: DataTable dt = ClassWorkInfoBLL.GetStuWorkList(UserID, PageIndex, PageSize); var data = from item in dt.AsEnumerable() group item by new { t1 = it 阅读全文
posted @ 2018-01-19 15:59 邢帅杰 阅读(179) 评论(0) 推荐(0) 编辑
把Linq查询返回的var类型的数据 转换为DataTable EF连接查询
摘要:问题:我要获得一个角色下对应的所有用户,需要两表连接查询,虽然返回的只有用户数据,但是我想到若是返回的不只是用户数据,而还要加上角色信息,那么我返回什么类型呢,返回var吗,这样不行。 于是我网上找找是否能返回DataTable呢,这样我不用创建中间类了。然后就找到下面的代码:这是别人写的,高手。 阅读全文
posted @ 2017-06-13 14:49 邢帅杰 阅读(1368) 评论(0) 推荐(0) 编辑
MVC中构建Linq条件、排序、Selector字段过滤
摘要:代码: 分别是 条件、排序、字段过滤。 阅读全文
posted @ 2017-05-31 17:29 邢帅杰 阅读(391) 评论(0) 推荐(0) 编辑
Linq多字段排序
摘要:var q = db.Customers.OrderBy(c => c.City).ThenBy(c => c.ContactName).ToList(); var q = from item in listAll orderby item.ParentID ascending, item.Sort 阅读全文
posted @ 2016-05-26 09:35 邢帅杰 阅读(356) 评论(0) 推荐(0) 编辑
Linq操作DataTable
摘要:IEnumerable<DataRow> q = from dr in dt.AsEnumerable() where dr.Field<int>("ID").ToString() == "1" select new { ID=dr["ID"].ToString(), Name=dr["Name"] 阅读全文
posted @ 2016-05-23 09:48 邢帅杰 阅读(138) 评论(0) 推荐(0) 编辑
如何很好的使用Linq的Distinct方法
摘要:测试数据 Person1: Id=1, Name="Test1" Person2: Id=1, Name="Test1" Person3: Id=2, Name="Test2" 以上list如果直接使用distinct方法进行过滤,仍然返回3条数据,而需要的结果是2条数据。下面给出解这个问题的方法: 阅读全文
posted @ 2016-02-25 16:49 邢帅杰 阅读(146) 评论(0) 推荐(0) 编辑
Linq select 语法
摘要:文档:https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b 1.可以对查询出来的结果做一些转换,下面的例子在数组中查找以"B"开头的名字,然后全部转成小写输出 string[] names = { "Jack", "Bob", "Bill 阅读全文
posted @ 2016-02-20 17:46 邢帅杰 阅读(967) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示