如何给网站做seo优化,网站建设工作策划书,wordpress xss漏洞利用,做家具定制的设计网站原本不支持 IQueryable 主要出于使用习惯的考虑#xff0c;如果继承 IQueryable#xff0c;编写代码的智能总会提示出现一堆你不想使用的方法#xff08;对不起#xff0c;我有强迫症#xff09;#xff0c;IQueryable 自身提供了一堆没法实现的方法#xff0c;还有外部… 原本不支持 IQueryable 主要出于使用习惯的考虑如果继承 IQueryable编写代码的智能总会提示出现一堆你不想使用的方法对不起我有强迫症IQueryable 自身提供了一堆没法实现的方法还有外部入侵的扩展方法严重影响编码体验。如下图 原以为必须实现 IQueryable 才可以实现结果一次惊喜原来只要有对应的方法就成。 虽然支持了但是还是推荐使用【链式 lambda】 特别说明 这次功能更新ISelect 增加了 5个方法对【链式 lambda】的用户可能会造成少许影响我在注释上标明了如下图 特别是 .Select()原先没有支持该功能与 ToList(a new Dto{}) 合并实现的。 需要避免一下坑 如果一定要使用 .Select() 方法请务必在 .ToList() 之前调用它请减少图中方法在【链式 labmda】模式下的使用 所有 ISelect 都可以使用 linq to sql包括 Repository、DbContext Where var t1 (from a in fsql.SelectStudent()where a.id item.idselect a
).ToList(); Select(指定字段) var t1 (from a in fsql.SelectStudent()where a.id item.idselect new { a.id }
).ToList(); CaseWhen var t1 (from a in fsql.SelectStudent()where a.id item.idselect new {a.id,a.name,testsub new {time a.age 10 ? 大于 : 小于或等于}}
).ToList(); Join var t1 (from a in fsql.SelectStudent()join b in fsql.SelectSchool() on a.id equals b.StudentIdselect a
).ToList();var t2 (from a in fsql.SelectStudent()join b in fsql.SelectSchool() on a.id equals b.StudentIdselect new { a.id, bid b.id }
).ToList();var t3 (from a in fsql.SelectStudent()join b in fsql.SelectSchool() on a.id equals b.StudentIdwhere a.id item.idselect new { a.id, bid b.id }
).ToList(); LeftJoin var t1 (from a in fsql.SelectStudent()join b in fsql.SelectSchool() on a.id equals b.StudentId into tempfrom tc in temp.DefaultIfEmpty()select a
).ToList();var t2 (from a in fsql.SelectStudent()join b in fsql.SelectSchool() on a.id equals b.StudentId into tempfrom tc in temp.DefaultIfEmpty()select new { a.id, bid tc.id }
).ToList();var t3 (from a in fsql.SelectStudent()join b in fsql.SelectSchool() on a.id equals b.StudentId into tempfrom tc in temp.DefaultIfEmpty()where a.id item.idselect new { a.id, bid tc.id }
).ToList(); From(多表查询) var t1 (from a in fsql.SelectStudent()from b in fsql.SelectSchool()where a.id b.StudentIdselect a
).ToList();var t2 (from a in fsql.SelectStudent()from b in fsql.SelectSchool()where a.id b.StudentIdselect new { a.id, bid b.id }
).ToList();var t3 (from a in fsql.SelectStudent()from b in fsql.SelectSchool()where a.id b.StudentIdwhere a.id item.idselect new { a.id, bid b.id }
).ToList(); GroupBy(分组) var t1 (from a in fsql.SelectStudent()where a.id item.idgroup a by new {a.id, a.name } into gselect new {g.Key.id, g.Key.name,cou g.Count(),avg g.Avg(g.Value.age),sum g.Sum(g.Value.age),max g.Max(g.Value.age),min g.Min(g.Value.age)}
).ToList(); 系列文章导航 一入门二自动迁移实体三实体特性四实体特性 Fluent Api五插入数据六批量插入数据七插入数据时忽略列八插入数据时指定列九删除数据十更新数据十一更新数据 Where十二更新数据时指定列十三更新数据时忽略列十四批量更新数据十五查询数据十六分页查询十七联表查询十八导航属性十九多表查询二十多表查询 WhereCascade二十一查询返回数据二十二Dto 映射查询二十三分组、聚合二十四Linq To Sql 语法使用介绍二十五延时加载二十六贪婪加载 Include、IncludeMany、Dto、ToList二十七将已写好的 SQL 语句与实体类映射进行二次查询二十八事务二十九Lambda 表达式三十读写分离三十一分区分表三十二Aop三十三CodeFirst 类型映射三十四CodeFirst 迁移说明三十五CodeFirst 自定义特性转载于:https://www.cnblogs.com/FreeSql/p/11531392.html