【发布时间】:2021-11-17 09:55:11
【问题描述】:
我已经关注EF.core(3.1/3.2)查询
var monthlySalesList = context.Bids.Include(r => r.AllRequest).ThenInclude(r => r.Category).Where(b => b.UID== UID && (b.Status == MyStatus.Awarded || b.Status == MyStatus.Completed))
.GroupBy(a => new { Month =a.InsertedDate.Month })
.Select(g => new MyServiceList()
{
Key = g.Key.ToString(),
Month = g.Key.Month.ToString(),
Total= g.Sum(s => s.totalBudget)
}).ToList();
我没有得到一年中的所有月份,而是只显示 2 个月,例如 (10,11)。在上面的查询中,Mystatus 是一个 ENUM 类,MyserviceList Model 类包含获取和设置,例如 @987654325 @.
我只得到
-----------------
Months total
------------------
10 1234
11 1212
如何获得零值的剩余月份。
-----------------
Months total
------------------
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 1234
11 1212
12 0
【问题讨论】:
标签: entity-framework entity-framework-core