这是我的SQL命令:我需要SQL转换到LINQ
select
b.Brand,
count(b.Brand) as BrandCount,
SUM(a.Qty) as DeviceCount
from (
select * from DeviceList
) as a
join DeviceMaster as b
on a.DeviceMasterId = b.Id
group by b.Brand
这是我到目前为止已经试过:
var v1 = (from p in ghostEntities.DeviceMasters
join c in ghostEntities.DeviceLists on p.Id equals c.DeviceMasterId
select new table_Model {
Id = c.Id,
qty = c.Qty.Value,
month = c.DMonth,
brand = p.Brand,
model = p.Model,
memory = p.Memory
}).ToList();
我得到的值形成两个表,但能对它们进行分组或添加值。
VAR V1 =(从ghostEntities.DeviceMasters p 将C在p.Id ghostEntities.DeviceLists等于c.DeviceMasterId 选择新table_Model { 编号= c.Id, 数量= c.Qty.Value, 月= c.DMonth, 品牌= p.Brand , model = p.Mod el, memory = p.Memory })。ToList(); –
我正在从两个表中获取值......但不能将它们分组或添加值.. –