이 간단한 E-SQL 쿼리와 저를 도와주세요 도와주세요 :엔티티는 SQL 그룹 문제,
var qStr = "SELECT SqlServer.Month(o.DatePaid) as month, SqlServer.Sum(o.PaidMoney) as PaidMoney FROM XACCModel.OrdersIncomes as o group by SqlServer.Month(o.DatePaid)";
여기 내가 가진거야.
나는 간단한 엔티티가 ID,PaidMoney,DatePaid,Order_ID
속성이 같은 달 합계 PaidMoney을 선택합니다
OrdersIncomes
라고 있습니다
month Paidmoney
1 500
2 700
3 1200
T-SQL looks like this and works fine:
select MONTH(o.DatePaid), SUM(o.PaidMoney)
from OrdersIncomes as o
group by MONTH(o.DatePaid)
results:
-----------
3 31.0000
4 127.0000
5 20.0000
(3 row(s) affected)
하지만 E-SQL 작업을 doesnot 내가 무엇을 잘 모릅니다. 필요가 여기 내 E-SQL 리팩토링 :
예외가있다var qStr = "SELECT SqlServer.Month(o.DatePaid) as month, SqlServer.Sum(o.PaidMoney) as PaidMoney FROM XACCModel.OrdersIncomes as o group by SqlServer.Month(o.DatePaid)";
: ERRORDESCRIPTION는 "이 집계 함수 나 GROUP BY 절 내에 포함되지 않기 때문에 'O'식별자가 유효하지 않습니다."=
다음과 같이 group by 절에 o를 포함하는 경우 FROM XACCModel.OrdersIncomes as o group by o
결과가 합산되지 않습니다. 이것은 버그입니까, 아니면 내가 잘못하고있는 것이 있습니까?
는 여기에 Linq에 엔티티에 대한 쿼리와 너무 작동합니다
var incomeResult = from ic in _context.OrdersIncomes
group ic by ic.DatePaid.Month into gr
select new { Month = gr.Key, PaidMoney = gr.Sum(i => i.PaidMoney) };
감사 등 SqlServer.Month (o.DatePaid)에 의해 O 기 등 SqlServer.Sum (o.PaidMoney)! . . . . . . . . . – Zviadi