private void MakeLineUp() { DataMaker.Manager mgr = new DataMaker.Manager(); try { Util.DatabaseManager dbMgr = new Util.DatabaseManager(); var matches = from match in dbMgr.SelectAll <Match>() join lineUp in dbMgr.SelectAll <LineUp>() on match.Id equals lineUp.MatchId into t from subLineUp in t.DefaultIfEmpty() where subLineUp == null select match; foreach (var match in matches) { var boxScore = (from b in dbMgr.SelectAll <BoxScore_W>() where b.GameId == match.GameId select b).First(); var lineUps = mgr.MakeLineUp(match.Id, boxScore); dbMgr.Save <LineUp>(lineUps); } } finally { } }
private void MakeMatch() { DataMaker.Manager mgr = new DataMaker.Manager(); Util.DatabaseManager dbMgr = new Util.DatabaseManager(); var schedules = from schedule in dbMgr.SelectAll <Schedule>() join match in dbMgr.SelectAll <Match>() on schedule.GameId equals match.GameId into t from subMatch in t.DefaultIfEmpty() where schedule.LeagueId == 1 && schedule.SeriesId == 0 && schedule.Href != null && subMatch.GameId == null select schedule; foreach (var schedule in schedules) { dbMgr = new Util.DatabaseManager(); var situation = (from s in dbMgr.SelectAll <Situation_W>() where s.GameId == schedule.GameId select s).First(); var boxScore = (from b in dbMgr.SelectAll <BoxScore_W>() where b.GameId == schedule.GameId select b).First(); var match = mgr.MakeMatch(situation, boxScore); // Match 저장 List <Match> matchs = new List <Match>(); matchs.Add(match); dbMgr.Save <Match>(matchs); // Th 저장 List <Th> ths = new List <Th>(); foreach (var th in match.Ths) { th.MatchId = match.Id; ths.Add(th); } dbMgr.Save <Th>(ths); // Bat 저장 List <Bat> bats = new List <Bat>(); foreach (var th in match.Ths) { if (th.Bats != null) { foreach (var bat in th.Bats) { bat.ThId = th.Id; bats.Add(bat); } } } dbMgr.Save <Bat>(bats); // Ball 저장 List <Ball> balls = new List <Ball>(); foreach (var th in match.Ths) { if (th.Bats != null) { foreach (var bat in th.Bats) { foreach (var ball in bat.Balls) { ball.BatId = bat.Id; balls.Add(ball); } } } } dbMgr.Save <Ball>(balls); } }