時間通りに返却されなかった本の延滞料を保存するビューがあります。コントローラー アクションでそれを行う方法は次のとおりです。
[HttpPost()]
public ActionResult DisplayTotalBalance(string id)
{
DataContext db = new DataContext();
var totalLateFee = (from p in db.vwCustomer.Where(a => a.CustomerId == id)
group p by p.LateFee into g
select g.Key).FirstOrDefault();
return Json(new { totalLateFee });
}
ここで延滞料金を保存する vwCustomer には、顧客に多くの延滞料金がリストされている場合があります。例えば
CustomerId LateFee
J101 5.0
P202 6.0
J101 2.0
P203 5.0
J101 5.0
J101 のすべての LateFee を合計して、コントローラー アクションで返すにはどうすればよいですか?