public ActionResult Statistics() { var data = repo.All() .Select(c => new 客戶統計ViewModel() { Id = c.Id, 客戶名稱 = c.客戶名稱 }).ToList(); foreach (var item in data) { item.銀行帳戶數量 = bankRepo.Count(item.Id); item.聯絡人數量 = contactRepo.Count(item.Id); } return(View(data)); }