private List<Pick> GetBestBatters(Match match) { List<Pick> picks = new List<Pick>(); var lineUps = dbMgr.SelectAll<LineUp>(); // 홈팀 타자 가지고오기 var homeTeamLineUps = from l in lineUps where l.MatchId == match.Id && l.AttackType == AttackType.Home && l.EntryType == EntryType.Starting select l; if(homeTeamLineUps.Count() >= 3) { homeTeamLineUps = homeTeamLineUps.Take(3); } // 어웨이팀 타자 가지고 오기 var awayTeamLineUps = from l in lineUps where l.MatchId == match.Id && l.AttackType == AttackType.Away && l.EntryType == EntryType.Starting select l; if (awayTeamLineUps.Count() >= 4) { awayTeamLineUps = awayTeamLineUps.Take(4); } // 투수 가지고 오기 var matchs = dbMgr.SelectAll<Match>(); var schedules = dbMgr.SelectAll<Schedule>(); var ths = dbMgr.SelectAll<Th>(); var bats = dbMgr.SelectAll<Bat>(); var players = dbMgr.SelectAll<Player>(); var queryTh = from m in matchs join s in schedules on m.GameId equals s.GameId join t in ths on m.Id equals t.MatchId where m.GameId == match.GameId && t.Number == 1 select t; var queryPitcher = (from t in queryTh join b in bats on t.Id equals b.ThId join p in players on b.PitcherId equals p.PlayerId where b.DetailResult.StartsWith("1번") select new { PlayerId = p.PlayerId, Name = p.Name }).ToList(); var homeTeamPitcher = queryPitcher.ToList()[0]; var awayTeamPitcher = queryPitcher.ToList()[1]; // 투수별 레벨구하기 String hPitcherLevel = GetLevel(homeTeamPitcher.PlayerId); String aPitcherLevel = GetLevel(awayTeamPitcher.PlayerId); foreach (var batter in homeTeamLineUps) { var ratio = CalcRatio(match.GameId, batter.PlayerId, awayTeamPitcher.PlayerId, aPitcherLevel); var pick = new Pick(); pick.MatchId = match.Id; pick.PlayerId = batter.PlayerId; pick.Ratio = ratio; picks.Add(pick); } foreach (var batter in awayTeamLineUps) { var ratio = CalcRatio(match.GameId, batter.PlayerId, homeTeamPitcher.PlayerId, hPitcherLevel); var pick = new Pick(); pick.MatchId = match.Id; pick.PlayerId = batter.PlayerId; pick.Ratio = ratio; picks.Add(pick); } return picks; }
private List <Pick> GetBestBatters(Match match) { List <Pick> picks = new List <Pick>(); var lineUps = dbMgr.SelectAll <LineUp>(); // 홈팀 타자 가지고오기 var homeTeamLineUps = from l in lineUps where l.MatchId == match.Id && l.AttackType == AttackType.Home && l.EntryType == EntryType.Starting select l; if (homeTeamLineUps.Count() >= 3) { homeTeamLineUps = homeTeamLineUps.Take(3); } // 어웨이팀 타자 가지고 오기 var awayTeamLineUps = from l in lineUps where l.MatchId == match.Id && l.AttackType == AttackType.Away && l.EntryType == EntryType.Starting select l; if (awayTeamLineUps.Count() >= 4) { awayTeamLineUps = awayTeamLineUps.Take(4); } // 투수 가지고 오기 var matchs = dbMgr.SelectAll <Match>(); var schedules = dbMgr.SelectAll <Schedule>(); var ths = dbMgr.SelectAll <Th>(); var bats = dbMgr.SelectAll <Bat>(); var players = dbMgr.SelectAll <Player>(); var queryTh = from m in matchs join s in schedules on m.GameId equals s.GameId join t in ths on m.Id equals t.MatchId where m.GameId == match.GameId && t.Number == 1 select t; var queryPitcher = (from t in queryTh join b in bats on t.Id equals b.ThId join p in players on b.PitcherId equals p.PlayerId where b.DetailResult.StartsWith("1번") select new { PlayerId = p.PlayerId, Name = p.Name }).ToList(); var homeTeamPitcher = queryPitcher.ToList()[0]; var awayTeamPitcher = queryPitcher.ToList()[1]; // 투수별 레벨구하기 String hPitcherLevel = GetLevel(homeTeamPitcher.PlayerId); String aPitcherLevel = GetLevel(awayTeamPitcher.PlayerId); foreach (var batter in homeTeamLineUps) { var ratio = CalcRatio(match.GameId, batter.PlayerId, awayTeamPitcher.PlayerId, aPitcherLevel); var pick = new Pick(); pick.MatchId = match.Id; pick.PlayerId = batter.PlayerId; pick.Ratio = ratio; picks.Add(pick); } foreach (var batter in awayTeamLineUps) { var ratio = CalcRatio(match.GameId, batter.PlayerId, homeTeamPitcher.PlayerId, hPitcherLevel); var pick = new Pick(); pick.MatchId = match.Id; pick.PlayerId = batter.PlayerId; pick.Ratio = ratio; picks.Add(pick); } return(picks); }