【发布时间】:2016-04-06 15:23:51
【问题描述】:
我有一个结构如下的数据库表:
- ID 整数自动增量
- 名称 VarChar
- 状态 VarChar
样本记录:
ID Name Status
1 record 1 Outstanding
2 record 2 Outstanding
3 record 3 Aging
4 record 4 Outstanding
5 record 5 Aging
6 record 6 Outstanding
在表格中,主要有两种状态:“杰出”和“老化”。我想统计表中有多少条状态为“Outstanding”的记录以及多少条状态为“Aging”的记录。
这是一个示例 LINQ 查询:
Using DC = DataClassesDataContext.Create()
Dim dataTable = From Count(Outstanding), Count(Aging) In DC.MyTable _
Where item.Status = "Outstanding" OrElse item.Status = "Aging" _
Group By item.Status _
Select item
End Using
预期的结果应该是:
Outstanding Aging
4 2
你能帮我设计一个 LINQ 来实现结果吗?
【问题讨论】: