【发布时间】:2019-11-26 19:58:22
【问题描述】:
我在 SQL Server 中运行此查询:
SELECT
COUNT(SERIAL) AS [Cantidad de computadoras entregadas],
FechaEntrega AS [Fecha de Entrega]
FROM
Inventary
WHERE
Modelo = 0 AND FechaEntrega > '2001-01-01 10:48:47.0000000'
GROUP BY
FechaEntrega
ORDER BY
FechaEntrega
我尝试使用 C# 方法制作该表,但我不明白,显然,我误用了 GroupBy() 方法
<table>
<thead>
<tr>
<th>Fecha</th>
</tr>
</thead>
<tbody>
@foreach(
var item in Model.Inventary
.Where(m => m.Modelo == 0)
.Where(f => f.FechaEntrega.Year > 2005)
.GroupBy( e => e.FechaEntrega)
)
{
<tr>
<td>
@Html.DisplayNameFor(modelItem => item.FechaEntrega)
</td>
</tr>
}
</tbody>
</table>
【问题讨论】:
-
也许我的SQL to LINQ Recipe 可以帮助你。请注意,您的 Razor 运行的查询与您的 SQL 不同(
Count在哪里?)
标签: sql-server entity-framework linq asp.net-core