分组:
日期分组一:
var result = await temp
.GroupBy("date_format(Day,'%Y-%m')")
.Select(s => new ViewModel.Managerment.MemberAmountChartView()
{
Month = SqlFunc.MappingColumn(s.Day, "date_format(Day,'%Y-%m')"),
TotalMember = SqlFunc.AggregateSum(s.IsMember) + SqlFunc.AggregateSum(s.NotMember),
IsMember = SqlFunc.AggregateSum(s.IsMember),
NotMember = SqlFunc.AggregateSum(s.NotMember)
}).ToListAsync();
日期分组二:
temp = temp.GroupBy(s => SqlFunc.DateValue(s.Date, DateType.Year))
.GroupBy(s => SqlFunc.DateValue(s.Date, DateType.Month));
var result = await temp.Select(s => new
{
CollectAmount = SqlFunc.AggregateSum(s.CollectAmount),
Year = SqlFunc.DateValue(s.Date, DateType.Year),
Month = SqlFunc.DateValue(s.Date, DateType.Month)
}).ToListAsync();
eChatsRes.X = result.Select(s => $"{s.Year}-{s.Month}").ToList();
eChatsRes.Y = result.Select(s => s.CollectAmount).ToList();