コード例 #1
0
        public List <MatchScoreView> GetForCompetition(int competitionId)
        {
            using (var db = new FiflackDbContext())
            {
                var matches =
                    from ms in db.MatchScores
                    join cm in db.CompetitionMatches on ms.Id equals cm.Match.Id
                    join p1 in db.Players on ms.PlayerId_1 equals p1.Id
                    join p2 in db.Players on ms.PlayerId_2 equals p2.Id
                    where cm.Competition.Id == competitionId
                    select new MatchScoreView
                {
                    Id            = ms.Id,
                    PlayerId_1    = ms.PlayerId_1,
                    PlayerId_2    = ms.PlayerId_2,
                    PlayerName_1  = p1.Name,
                    PlayerName_2  = p2.Name,
                    PlayerGoals_1 = ms.GoalsOfPlayer_1,
                    PlayerGoals_2 = ms.GoalsOfPlayer_2
                };

                return(matches.ToList());
            }
        }