コード例 #1
0
 public static decimal GetAverageGoalForCompetition(int competitionId)
 {
     using (var db = new sakilaEntities4())
     {
         var matches      = MainCalculator.GetAllMatchesForCompetition(competitionId, db);
         var sumHomeGoals = matches.Sum(x => x.HomeGoals);
         var sumAwayGoals = matches.Sum(x => x.AwayGoals);
         return((decimal)(sumAwayGoals + sumHomeGoals) / matches.Count);
     }
 }