私はこのテーブルを持っています:
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 Razor):
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.friend)
</td>
</tr>
}