zoukankan      html  css  js  c++  java
  • EF-联合查询-结果集-Group by-统计数目

    EF框架用着痛并且快乐着···

    毕竟用习惯了SQL语句直接硬查的···

    SELECT C0.ID,C_C.Name,C_C.C_COUNT FROM article_type C0 
    INNER JOIN(SELECT C.Name,COUNT(C.Name) AS C_COUNT FROM article_type C 
    INNER JOIN article_Info A ON C.ID = A.SeventSortID GROUP BY C.Name) C_C ON C0.Name = C_C.Name

    但是项目中用的EF、改吧、搜来搜去总算给拼出来了、、、

    也算是EF进程中的一个进步吧···

                    var count =
                        (from e_ in db.article_type
                         join a_a in
                        (from a in db.article_Info
                         from e in db.article_type
                         where a.SeventSortID == e.ID
                         group e by e.Name into g
                         select new
                         {
                             g.Key,
                             Count_ = g.Count()
                         }) on e_.Name equals a_a.Key
                         select new
                         {
                             ID = e_.ID,
                             Name = e_.Name,
                             count = a_a.Count_
                         }).ToList();

    。。。

  • 相关阅读:
    H5 _拖放使用
    CSS _text-align:justify;实现两端对齐
    Tips_钉钉免登前端实现
    快速组建的开发团队要怎么活下来?
    程序员,你的安全感呢?
    从自我驱动到带领10人团队
    你会给别人提反馈吗?
    简单几步成为微信公众平台开发者
    你了解javascript中的function吗?(1)
    容器之路 HashMap、HashSet解析(一)
  • 原文地址:https://www.cnblogs.com/love-zf/p/5953560.html
Copyright © 2011-2022 走看看