如何在EF中对数据进行两次分组?
这是我当前的 LINQ 查询:
var list_1 = from z in _uow.Events.FindAll()
group z by new
{
z.GroupOfEvents.Customer,
z.GroupOfEvents.GroupOfGroupOfEvents.Data.Year,
z.GroupOfEvents.GroupOfGroupOfEvents.Data.Month,
z.GroupOfEvents.GroupOfGroupOfEvents.Data.Day
}
into zz
select new
{
zz.Key.Customer.Id,
zz.Key.Year,
zz.Key.Month,
zz.Key.Day,
Amount = zz.Sum(a => a.Amount)
};
我想获取按客户 ID 分组的数据,然后按天(年月日)分组的数据。所以我想访问每个客户每天的特定“金额”。知道怎么做吗?
This is my current LINQ query:
var list_1 = from z in _uow.Events.FindAll()
group z by new
{
z.GroupOfEvents.Customer,
z.GroupOfEvents.GroupOfGroupOfEvents.Data.Year,
z.GroupOfEvents.GroupOfGroupOfEvents.Data.Month,
z.GroupOfEvents.GroupOfGroupOfEvents.Data.Day
}
into zz
select new
{
zz.Key.Customer.Id,
zz.Key.Year,
zz.Key.Month,
zz.Key.Day,
Amount = zz.Sum(a => a.Amount)
};
I would like to get data grouped by customer id, and then by day (year-month-day). So I want to access particular "Amount" per customer per day. Any idea how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
到目前为止,我已经做到了,但我不确定这是否是最好的方法?
So far I came with this, but I'm not sure if this is the best way?