/// <summary> /// Loads players from the specified club. /// </summary> /// <param name="club">Club.</param> internal void LoadPlayers(ClubData club) { PlayerData.ClearInstances(); SetList("player", new[] { "ID", "Firstname", "Lastname", "Commonname", "DateOfBirth", "YearOfBirth", "CurrentAbility", "PotentialAbility", "HomeReputation", "CurrentReputation", "WorldReputation", "RightFoot", "LeftFoot", "NationID1", "NationID2", "ClubContractID", "DateContractStart", "DateContractEnd", "Value", "Wage", "Caps", "IntGoals" }, (SqlDataReader reader) => { return(new PlayerData(reader.Get <int>("ID"), reader.Get <string>("Firstname"), reader.Get <string>("Lastname"), reader.Get <string>("Commonname"), reader.Get <DateTime?>("DateOfBirth"), reader.Get <int?>("YearOfBirth"), reader.Get <int>("CurrentAbility", new Tuple <int, int>(0, 100)), reader.Get <int>("PotentialAbility", new Tuple <int, int>(0, 100), new Tuple <int, int>(-1, 140), new Tuple <int, int>(-2, 180)), reader.Get <int>("HomeReputation", new Tuple <int, int>(0, 100)), reader.Get <int>("CurrentReputation", new Tuple <int, int>(0, 100)), reader.Get <int>("WorldReputation", new Tuple <int, int>(0, 100)), reader.Get <int>("RightFoot"), reader.Get <int>("LeftFoot"), CountryData.GetByid(reader.Get <int?>("NationID1")), CountryData.GetByid(reader.Get <int?>("NationID2")), ClubData.GetByid(reader.Get <int?>("ClubContractID")), reader.Get <DateTime?>("DateContractStart"), reader.Get <DateTime?>("DateContractEnd"), reader.Get <int>("Wage"), reader.Get <int>("Value"), reader.Get <int>("Caps"), reader.Get <int>("IntGoals"))); }, "ISNULL([ClubContractID], " + Constants.NoClubId.ToString() + ") = @club", new SqlParameter("@club", club.Id)); using (var conn = new SqlConnection(Settings.Default.connectionString)) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@player", System.Data.SqlDbType.BigInt); GetDatasRelativeToPlayer(cmd, "position", (PlayerData p, PositionData position, int rate) => { p.SetPosition(position, rate); }, (int value) => { return((PositionData)value); }); GetDatasRelativeToPlayer(cmd, "side", (PlayerData p, SideData side, int rate) => { p.SetSide(side, rate); }, (int value) => { return((SideData)value); }); GetDatasRelativeToPlayer(cmd, "attribute", (PlayerData p, AttributeData attribute, int rate) => { p.SetAttribute(attribute, rate); }, (int value) => { return(AttributeData.GetByid(value)); }); } } foreach (PlayerData p in PlayerData.Instances) { p.AdjustPositionAndSide(); } }