Skip to content

Instantly share code, notes, and snippets.

Created March 7, 2018 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ceb3247cdd6483afecc6b3dfbc09865c to your computer and use it in GitHub Desktop.
Save anonymous/ceb3247cdd6483afecc6b3dfbc09865c to your computer and use it in GitHub Desktop.
Entity Framework
for (var round = 1; round <= width; round++)
{
// Round
var tournamentRound = new SingleKnockoutRound();
tournamentRound.Tournament = this;
tournamentRound.Matches = new List<TournamentMatch>();
dbContext.TournamentRounds.Add(tournamentRound);
this.Rounds.Add(tournamentRound);
for (var m = 0; m < nrOfMatches; m++)
{
// TournamentMatch
var tournamentMatch = new TournamentMatch();
dbContext.TournamentMatches.Add(tournamentMatch);
tournamentRound.Matches.Add(tournamentMatch);
// Match
var match = new Match();
dbContext.Matches.Add(match);
tournamentMatch.Match = match;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment