0
是否有人計算百分比在LINQ到實體任何提示?LINQ到實體百分比
我猜一定有比返回2周的結果,並在內存計算更有效的方式。也許創造性地使用let或into?
編輯
感謝馬克的評論,這裏是一個代碼片段,但我認爲這將導致2的數據庫訪問:
int passed = (from lpt in this.PushedLearnings.Select(pl => pl.LearningPlanTask)
where lpt.OnlineCourseScores.Any(score => score.ActualScore >= ((lpt.LearningResource.PassMarkPercentage != (decimal?)null) ?lpt.LearningResource.PassMarkPercentage : 80))
select lpt).Count();
int total = (from lpt in this.PushedLearnings.Select(pl => pl.LearningPlanTask)
select lpt).Count();
double percentage = passed * 100/total;
你可以發佈你的代碼? –
感謝@MarkByers我在代碼示例中彈出。 –