これが私のアクションコードです
public class personnelViewModel{
public Guid PKPersonelID { get; set; }
public string name { get; set; }
public string family { get; set; }
public int usageCount { get; set; }
}
var model = from personnel in DB.RFH_Personnel select new personnelViewModel
{
PKPersonelID = personnel.PKPersonelID,
name = personnel.Name,
family = personel.Family
}
freach(var item in model)
item.usageCount = DB.RFH_Service.Count(d => d.FKPersonelID == item.PKPersonelID);
return View(model);
これが私の見解です:
@model IEnumerable<RefahiWeb.Models.personnelViewModel>
@{
var grid = new WebGrid(source: Model, rowsPerPage: 15, canPage: true, canSort: true);
}
@grid.GetHtml(tableStyle: "table tablesorter table-bordered table-hover request-status",
mode: WebGridPagerModes.All,
columns: grid.Columns(
grid.Column("name", "name", canSort: false),
grid.Column("family", "family", canSort: false),
grid.Column("usageCount", "usageCount", canSort: false)
)
)
問題は、usageCount が常にゼロに設定され、froeach ループで設定された値が usageCount の値を変更しないことです。どんな助けでも事前に感謝します。