如何在一个 LINQ 上获取子值的总和
这是我的结构:
程序 - 描述等...
操作 - Program_Id、描述等。
成本 - Action_Id、Value1、Value2、Value3
一个操作可以有多个成本。 我需要的是一个按程序对这些值进行分组的查询。例如:
“程序名称”|总价值1 |总价值 2 |计划总计
这是我迄今为止的努力:
var ListByPrograma = from a in db.Actions
join c in db.Costs on a.Id equals c.Action_Id
group a by a.Program into p
select new
{
Program = p.Key,
actionsQuantity = p.Count(),
totalValue1 = p.Costs.????
totalValue2 = ?,
totalByProgram = ?
};
This is the structure I have:
Program
- Description, etc...
Action
- Program_Id, Description, etc..
Cost
- Action_Id, Value1, Value2, Value3
One Action can Have multiple Costs.
What I Need is a query that group this values by Program. Like:
"Program name" | Total of Value1 | Total of Value 2 | Total of the program
This is my effort so far:
var ListByPrograma = from a in db.Actions
join c in db.Costs on a.Id equals c.Action_Id
group a by a.Program into p
select new
{
Program = p.Key,
actionsQuantity = p.Count(),
totalValue1 = p.Costs.????
totalValue2 = ?,
totalByProgram = ?
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样的东西有用吗?
Does something like this work?