Linq in asp.net

A quick sample of how to use linq in your webpages

 

[code:c#]

<% Model.ToList().ForEach(item =>
{ %>
  <tr>
      <td>
          <%: Html.ActionLink("Edit", "Edit", new { id = item.AlbumId })%> |
          <%: Html.ActionLink("Delete", "Delete", new { id = item.AlbumId })%>
      </td>
      <td><%: Html.Truncate(item.Title, 25)%></td>
      <td><%: Html.Truncate(item.Artist.Name, 25)%></td>
      <td><%: item.Genre.Name%></td>
  </tr>
<% }); %>

[/code]

 

I said quick ey!  :-)

Comments are closed