我正在尝试构建一个 Kendo 条形图。我需要打开的票数和关闭的票数。我需要按月分组的结果。这是我的 LINQ
Dim openTickets = (From t In queue _
Where _
(t.CreateDate.Year = Convert.ToDateTime(DateTime.Now).Year)
Group t By _
ID = CType(t.CreateDate.Month, Integer), _
Month = CType(t.CreateDate.ToString("MMMM"), String) _
Into g = Group _
Select New With _
{.Month = Month.Substring(0, 3), .Opened = g.Where(Function(t) t.CreateDate.Month = ID).Count(Function(t) t.Id)})
Dim closedTickets = (From t In queue _
Where _
(t.CloseDate.Year = Convert.ToDateTime(DateTime.Now).Year)
Group t By _
ID = CType(t.CloseDate.Month, Integer), _
Month = CType(t.CloseDate.ToString("MMMM"), String) _
Into g = Group _
Select New With _
{.Month = Month.Substring(0, 3), .Closed = g.Where(Function(t) t.CloseDate.Month = ID).Count(Function(t) t.Id)})
Dim ticketCount = openTickets.Union(closedTickets)
当我尝试这个时,我得到“WhereSelectEnumerableIterator”。如果我将第二个查询更改为名称为“.Opened”而不是“.Closed”,则它可以工作,但我不知道“已关闭”的计数。
最终我试图得到一个数组的输出来提供图表......类似于这个:
[{"Month":"Apr","Opened":138,"Closed":150}
INSTEAD OF
[{"Month":"Apr","Opened":138,"Closed":0},{"Month":"Apr","Opened":0,"Closed":150}