我有这张桌子:
我想friend
通过 LINQ 显示所有名称都没有重复。我该怎么做?结果是:
martin
kevin
igor
控制器:
dbEntities db = new dbEntities();
public ActionResult Index()
{
IQueryable<string> dn = from f in db.table select f.friend;
IQueryable<string> res = dn.Distinct();
return View(res);
}
查看(ASP.NET MVC 3 剃刀):
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.friend)
</td>
</tr>
}