【发布时间】:2017-07-26 20:38:36
【问题描述】:
我正在尝试返回一个月内有多少客户“注册”的结果。目前它返回每个特定日期的计数。见下文:
这是我的控制器中的代码:
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()
};
谁能建议我如何计算每月注册的客户数量?
提前致谢。
更新
使用时出现如下错误:
group customer by new { customer.EnrollmentDate.Year, customer.EnrollmentDate.Month } into dateGroup
【问题讨论】:
-
group customer by new { customer.EnrollmentDate.Year, customer.EnrollmentDate.Month }
标签: asp.net .net asp.net-mvc entity-framework entity-framework-4