MediaPlanBillingDetails
에서 MediaPlanPrint
로 이동하고 금액의 합계를 계산하는 가장 효율적인 방법은 무엇입니까? 기본적으로 MediaPlanBillingDetails는 기본 테이블입니다.내 linq 더 많은 엔티티 쿼리를 더 빨리 만드는 방법
현재 검색어 :
var sumofallbills= MediaPlanBillingDetails.Sum(m => m.MediaPlanRO.MediaPlanROPrints.Sum(qq => qq.MediaPlanPrint.Amount));
예 데이터 :
var aS = new List<MediaPlanBillingDetails>();
aS.Add(new MediaPlanBillingDetails { BillId = 1, RoID = 1 });
aS.Add(new MediaPlanBillingDetails { BillId = 1, RoID = 2 });
aS.Add(new MediaPlanBillingDetails { BillId = 2, RoID = 3 });
aS.Add(new MediaPlanBillingDetails { BillId = 2, RoID = 4 });
aS.Add(new MediaPlanBillingDetails { BillId = 3, RoID = 5 });
var bs = new List<MediaPlanRo>();
bs.Add(new MediaPlanRo { RoId = 1 });
bs.Add(new MediaPlanRo { RoId = 2 });
bs.Add(new MediaPlanRo { RoId = 3 });
bs.Add(new MediaPlanRo { RoId = 4 });
bs.Add(new MediaPlanRo { RoId = 5 });
var cs = new List<MediaPlanRoDetails>();
cs.Add(new MediaPlanRoDetails { PrintEstimateId = 1, RoId = 1 });
cs.Add(new MediaPlanRoDetails { PrintEstimateId = 2, RoId = 1 });
cs.Add(new MediaPlanRoDetails { PrintEstimateId = 3, RoId = 2 });
cs.Add(new MediaPlanRoDetails { PrintEstimateId = 4, RoId = 3 });
cs.Add(new MediaPlanRoDetails { PrintEstimateId = 5, RoId = 4 });
cs.Add(new MediaPlanRoDetails { PrintEstimateId = 6, RoId = 5 });
var ds = new List<MediaPlanPrint>();
ds.Add(new MediaPlanPrint { PrintEstimateId = 1, Amount = 1000 });
ds.Add(new MediaPlanPrint { PrintEstimateId = 2, Amount = 5000 });
ds.Add(new MediaPlanPrint { PrintEstimateId = 3, Amount = 6000 });
ds.Add(new MediaPlanPrint { PrintEstimateId = 4, Amount = 8000 });
ds.Add(new MediaPlanPrint { PrintEstimateId = 5, Amount = 9000 });
ds.Add(new MediaPlanPrint { PrintEstimateId = 6, Amount = 10000 });
* MediaPlanBillingDetails에서 MediaPlanPrint *로 이동한다는 것은 무엇을 의미합니까? –
나는 table1에서 table4로 바로 갈 수 없다는 뜻입니다. 나는 그들을 지나쳐 야한다 – maztt
* 무엇보다 * 빠름? 현재 쿼리가 어떻게 보이는지 보지 않고 말하기가 어렵습니다. –