• 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();

    。。。

  • 相关阅读:
    pandas(六):pandas对excel进行读写
    当方法类bean无法注入时
    js 替换css属性
    select既可以输入也可以下拉框选择
    Java 容器详解
    前端页面获取URL拼接的参数值
    web前端工程师需要掌握的技能
    小程序云开发图片上传存储
    小程序云开发删除‘存储’的图片或文件
    小程序云开发对数据库增删改查相关操作
  • 原文地址:https://www.cnblogs.com/love-zf/p/5953560.html
Copyright © 2020-2023  润新知