ビューに渡すユーザー プロファイルのリストを並べ替えるのに問題があります。特定の役割のすべてのユーザーのリストを表示し、それらを familyName 属性で並べ替えたいと考えています。
OrderBy を使用してみましたが、効果がありません。
コントローラー内のコード
public ActionResult Index()
{
//get all patients
var patients = Roles.GetUsersInRole("user").ToList();
//set up list of patient profiles
List<UserProfile> pprofiles = new List<UserProfile>();
foreach (var i in patients) {
pprofiles.Add(ZodiacPRO.Models.UserProfile.GetUserProfile(i));
}
pprofiles.OrderBy(x => x.familyName); //<-this has no effect the list produced is
// exactly the same it was without this line
return View(pprofiles);
}
そして、ビュー
<ul id= "patientList">
@foreach (var m in Model)
{
<li>
<ul class="patient">
<li class="ptitle">@m.title</li>
<li class="pname"> @Html.ActionLink(@m.givenName + " " + @m.familyName, "View", "Account", new { @username = @m.UserName.ToString() }, new { id = "try" })</li>
<li class="pprofile">@Ajax.ActionLink("Profile", "PatientSummary", new { @username = @m.UserName }, new AjaxOptions { UpdateTargetId = "pContent"},new{ @class = "profpic" })</li>
</ul>
</li>
}
</ul>
これを複数の場所で再利用する必要があり、多数のユーザーがいる可能性があるため、何らかの方法で注文しないとひどいことになります. これについてどうすればよいですか?