我試圖返回一個月內有多少客戶「註冊」的結果。目前它返回每個特定日期的計數。見下圖:按月計算的組數
這裏是我的控制器代碼:
public ActionResult About()
{
IQueryable<EnrollmentDateGroup> data = from customer in db.Customers
group customer by customer.EnrollmentDate into dateGroup
select new EnrollmentDateGroup()
{
EnrollmentDate = dateGroup.Key,
CustomerCount = dateGroup.Count()
};
任何人都可以建議我如何能有多少客戶每月招收的計數?
在此先感謝。
UPDATE
我收到以下錯誤,當我使用:
group customer by new { customer.EnrollmentDate.Year, customer.EnrollmentDate.Month } into dateGroup
'通過新的集團客戶{customer.EnrollmentDate.Year,customer.EnrollmentDate.Month}' –