public JsonResult GetAllWareHouse(int pageIndex = 1, int pageSize = 10) { int total = 0; IEnumerable <WareHouse> wareHouseList = wareHouseService.GetAllWareHouse(pageIndex, pageSize, out total).ToList(); var list = from wareHouse in wareHouseList select new { Id = wareHouse.Id, Name = wareHouse.Name, Location = wareHouse.Location, Capacity = wareHouse.Capacity, //该仓库的总共存货量 totalStorage = wareHouse.GoodsStorages.Sum(s => s.Quantity) }; return(Json(new { rows = list, total = total }, JsonRequestBehavior.AllowGet)); }