代码之家  ›  专栏  ›  技术社区  ›  Sergio Tapia

如何获得SQL结果中的项目总数?

  •  0
  • Sergio Tapia  · 技术社区  · 14 年前

    [代码]

    <h2>Listado General de Carreras</h2>
    
    <% foreach (var item in Model)
       { %>
    
       <p><span class="titulo"><%=Html.ActionLink(item.Nombre, "Details" , new { id = item.ID }) %></span> <sub> Area: <%: item.Area.Nombre%></sub></p>
    
    <% } %>    
    
    <p>
        <%: Html.ActionLink("Crear Nueva Carrera", "Create") %>
    </p>
    

    [/代码]

    我要做的是为数据库中的每个区域显示一个标题,并在每个区域下显示该区域有哪些职业。

    我在考虑使用Linq查询并将它们保存到ViewData[]中,但也许还有其他方法?

    1 回复  |  直到 14 年前
        1
  •  0
  •   griegs    14 年前

    你试过收藏的.Count属性了吗?