原本不支持 IQueryable 主要出于使用習(xí)慣的考慮,如果繼承
          IQueryable,編寫代碼的智能總會(huì)提示出現(xiàn)一堆你不想使用的方法(對(duì)不起,我有強(qiáng)迫癥),IQueryable
          自身提供了一堆沒法實(shí)現(xiàn)的方法,還有外部入侵的擴(kuò)展方法,嚴(yán)重影響編碼體驗(yàn)。如下圖:



          原以為必須實(shí)現(xiàn) IQueryable 才可以實(shí)現(xiàn),結(jié)果一次驚喜,原來只要有對(duì)應(yīng)的方法就成。

          雖然支持了,但是還是推薦使用【鏈?zhǔn)?+ lambda】 ?。?!

          特別說明

          這次功能更新,ISelect 增加了 5個(gè)方法,對(duì)【鏈?zhǔn)?+ lambda】的用戶可能會(huì)造成少許影響,我在注釋上標(biāo)明了,如下圖:



          特別是 .Select(),原先沒有支持,該功能與 ToList(a => new Dto{}) 合并實(shí)現(xiàn)的。

          需要避免一下坑:

          *
          如果一定要使用 .Select() 方法,請(qǐng)務(wù)必在 .ToList() 之前調(diào)用它;

          *
          請(qǐng)減少圖中方法在【鏈?zhǔn)?+ labmda】模式下的使用;

          所有 ISelect 都可以使用 linq to sql,包括 Repository、DbContext;

          Where
          var t1 = ( from a in fsql.Select<Student>() where a.id == item.id select a
          ).ToList();
          Select(指定字段)
          var t1 = ( from a in fsql.Select<Student>() where a.id == item.id select new {
          a.id } ).ToList();
          CaseWhen
          var t1 = ( from a in fsql.Select<Student>() where a.id == item.id select new {
          a.id, a.name, testsub = new { time = a.age > 10 ? "大于" : "小于或等于" } } ).ToList();
          Join
          var t1 = ( from a in fsql.Select<Student>() join b in fsql.Select<School>() on
          a.id equals b.StudentId select a ).ToList(); var t2 = ( from a in
          fsql.Select<Student>() join b in fsql.Select<School>() on a.id equals
          b.StudentId select new { a.id, bid = b.id } ).ToList(); var t3 = ( from a in
          fsql.Select<Student>() join b in fsql.Select<School>() on a.id equals
          b.StudentId where a.id == item.id select new { a.id, bid = b.id } ).ToList();
          LeftJoin
          var t1 = ( from a in fsql.Select<Student>() join b in fsql.Select<School>() on
          a.id equals b.StudentId into temp from tc in temp.DefaultIfEmpty() select a
          ).ToList(); var t2 = ( from a in fsql.Select<Student>() join b in
          fsql.Select<School>() on a.id equals b.StudentId into temp from tc in
          temp.DefaultIfEmpty() select new { a.id, bid = tc.id } ).ToList(); var t3 = (
          from a in fsql.Select<Student>() join b in fsql.Select<School>() on a.id equals
          b.StudentId into temp from tc in temp.DefaultIfEmpty() where a.id == item.id
          select new { a.id, bid = tc.id } ).ToList();
          From(多表查詢)
          var t1 = ( from a in fsql.Select<Student>() from b in fsql.Select<School>()
          where a.id == b.StudentId select a ).ToList(); var t2 = ( from a in
          fsql.Select<Student>() from b in fsql.Select<School>() where a.id ==
          b.StudentId select new { a.id, bid = b.id } ).ToList(); var t3 = ( from a in
          fsql.Select<Student>() from b in fsql.Select<School>() where a.id ==
          b.StudentId where a.id == item.id select new { a.id, bid = b.id } ).ToList();
          GroupBy(分組)
          var t1 = ( from a in fsql.Select<Student>() where a.id == item.id group a by
          new {a.id, a.name } into g select 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();
          系列文章導(dǎo)航

          *
          (一)入門 <https://www.cnblogs.com/FreeSql/p/11531300.html>

          *
          (二)自動(dòng)遷移實(shí)體 <https://www.cnblogs.com/FreeSql/p/11531301.html>

          *
          (三)實(shí)體特性 <https://www.cnblogs.com/FreeSql/p/11531302.html>

          *
          (四)實(shí)體特性 Fluent Api <https://www.cnblogs.com/FreeSql/p/11531304.html>

          *
          (五)插入數(shù)據(jù) <https://www.cnblogs.com/FreeSql/p/11531306.html>

          *
          (六)批量插入數(shù)據(jù) <https://www.cnblogs.com/FreeSql/p/11531309.html>

          *
          (七)插入數(shù)據(jù)時(shí)忽略列 <https://www.cnblogs.com/FreeSql/p/11531316.html>

          *
          (八)插入數(shù)據(jù)時(shí)指定列 <https://www.cnblogs.com/FreeSql/p/11531318.html>

          *
          (九)刪除數(shù)據(jù) <https://www.cnblogs.com/FreeSql/p/11531320.html>

          *
          (十)更新數(shù)據(jù) <https://www.cnblogs.com/FreeSql/p/11531321.html>

          *
          (十一)更新數(shù)據(jù) Where <https://www.cnblogs.com/FreeSql/p/11531324.html>

          *
          (十二)更新數(shù)據(jù)時(shí)指定列 <https://www.cnblogs.com/FreeSql/p/11531327.html>

          *
          (十三)更新數(shù)據(jù)時(shí)忽略列 <https://www.cnblogs.com/FreeSql/p/11531334.html>

          *
          (十四)批量更新數(shù)據(jù) <https://www.cnblogs.com/FreeSql/p/11531335.html>

          *
          (十五)查詢數(shù)據(jù) <https://www.cnblogs.com/FreeSql/p/11531339.html>

          *
          (十六)分頁查詢 <https://www.cnblogs.com/FreeSql/p/11531341.html>

          *
          (十七)聯(lián)表查詢 <https://www.cnblogs.com/FreeSql/p/11531346.html>

          *
          (十八)導(dǎo)航屬性 <https://www.cnblogs.com/FreeSql/p/11531352.html>

          *
          (十九)多表查詢 <https://www.cnblogs.com/FreeSql/p/11531362.html>

          *
          (二十)多表查詢 WhereCascade <https://www.cnblogs.com/FreeSql/p/11531372.html>

          *
          (二十一)查詢返回?cái)?shù)據(jù) <https://www.cnblogs.com/FreeSql/p/11531376.html>

          *
          (二十二)Dto 映射查詢 <https://www.cnblogs.com/FreeSql/p/11531381.html>

          *
          (二十三)分組、聚合 <https://www.cnblogs.com/FreeSql/p/11531384.html>

          *
          (二十四)Linq To Sql 語法使用介紹

          *
          (二十五)延時(shí)加載 <https://www.cnblogs.com/FreeSql/p/11531395.html>

          *
          (二十六)貪婪加載 Include、IncludeMany、Dto、ToList
          <https://www.cnblogs.com/FreeSql/p/11531404.html>

          *
          (二十七)將已寫好的 SQL 語句,與實(shí)體類映射進(jìn)行二次查詢
          <https://www.cnblogs.com/FreeSql/p/11531416.html>

          *
          (二十八)事務(wù) <https://www.cnblogs.com/FreeSql/p/11531423.html>

          *
          (二十九)Lambda 表達(dá)式 <https://www.cnblogs.com/FreeSql/p/11531425.html>

          *
          (三十)讀寫分離 <https://www.cnblogs.com/FreeSql/p/11531430.html>

          *
          (三十一)分區(qū)分表 <https://www.cnblogs.com/FreeSql/p/11531435.html>

          *
          (三十二)Aop <https://www.cnblogs.com/FreeSql/p/11531471.html>

          *
          (三十三)CodeFirst 類型映射 <https://www.cnblogs.com/FreeSql/p/11531543.html>

          *
          (三十四)CodeFirst 遷移說明 <https://www.cnblogs.com/FreeSql/p/11531550.html>

          *
          (三十五)CodeFirst 自定義特性 <https://www.cnblogs.com/FreeSql/p/11531576.html>

          友情鏈接
          ioDraw流程圖
          API參考文檔
          OK工具箱
          云服務(wù)器優(yōu)惠
          阿里云優(yōu)惠券
          騰訊云優(yōu)惠券
          京東云優(yōu)惠券
          站點(diǎn)信息
          問題反饋
          郵箱:[email protected]
          QQ群:637538335
          關(guān)注微信

                少妇口述交换夫全经历 | 爱搞精品 | 看欧美一级片 | 男人躁女人过程无遮挡网站 | 干大逼|