在LINQ中选择多个总和最大的列

时间:2018-12-14 16:00:31

标签: linq

我有三个桌子

device (id,device_name)
operation (id,type"Sell,Add to Store")
operation_device (id,operation_id,device_id,Quantity)

我想知道销售最多的设备(名称+数量)

var q = from s in db.device_operation
                join k in db.operation
                on s.operationId equals k.Id
                where k.type == "Sell"
                group s by s.deviceId into g

                select  g.Sum(s => s.Quantity);

0 个答案:

没有答案
相关问题