实体框架嵌套选择查询

时间:2013-05-03 07:46:56

标签: c# sql linq entity-framework

我有一个SQL查询,我应该在Entity Framework中使用它。我是Entity的新手,我不知道如何做到这一点。我的疑问是:

SELECT EKIP,
       COUNT (SAGLA) AS KPISAYISI
FROM
  (SELECT M.APPLICATIONID AS ORTAM,
          MNAME AS SERVIS,
          sum(AVAIL*HIT)/SUM(HIT) AS SAGLA,
          SUM(HIT) AS CAGRI ,

     (SELECT DOMAINNAME
      FROM SOAGOVERNANCE_SERVICE D
      WHERE D.NAME=m.MNAME
        AND D.APPLICATIONID=m.APPLICATIONID) AS EKIP
   FROM SOAGOVERNANCE_METRICLOG m
   WHERE MDATE BETWEEN '2013-01-01 01:00:00' AND '2013-02-01 01:00:00'
     AND MTYPE='SERVICE'
   GROUP BY APPLICATIONID,
            MNAME) S
WHERE S.CAGRI > 3
  AND S.SAGLA<90
GROUP BY EKIP
ORDER BY EKIP

1 个答案:

答案 0 :(得分:0)

最简单的方法是使用查询创建sql视图。 然后在视图上创建实体。

或者您想在实体中进行完整查询?