有一条sql语句
select SUM(num1) a1 , SUM(num2) a2, SUM(num3) a3
from Table1
写出对应的Lambda表达式:
要求:
var query = context.Orders
.GroupBy(o =>true)
.Select(g => new
{
Sum = g.Sum(o => o.Amount),
Min = g.Min(o => o.Amount),
Max = g.Max(o => o.Amount),
Avg = g.Average(o => Amount)
});
ef core 中的写法
谢谢,我之前试过要分组才能写聚合函数,但是不晓得怎么写,没想到竟然是 GroupBy(o =>true)
感觉这么写有点奇怪,但是对的