public static SQLPlayerGearGems CreateEmpty() { SQLPlayerGearGems value = new SQLPlayerGearGems(); value.Gems = new Dictionary <ItemSlot, SQLGemInfo>(); return(value); }
public bool GetPlayerGearGems(SQLPlayerData _PlayerData, out SQLPlayerGearGems _ResultGearGems) { var conn = OpenConnection(); try { const int ITEMSLOT_COLUMN = 0; const int GEMID1_COLUMN = 1; const int GEMID2_COLUMN = 2; const int GEMID3_COLUMN = 3; const int GEMID4_COLUMN = 4; using (var cmd = new NpgsqlCommand("SELECT itemslot, gemid1, gemid2, gemid3, gemid4 FROM PlayerGearGemsTable WHERE gearid=:ID", conn)) { { var idParam = new NpgsqlParameter("ID", NpgsqlDbType.Integer); idParam.Value = (int)_PlayerData.PlayerGearID; cmd.Parameters.Add(idParam); } using (var reader = cmd.ExecuteReader()) { if (reader.HasRows == true) { _ResultGearGems = SQLPlayerGearGems.CreateEmpty(); while (reader.Read() == true) { SQLGemInfo gemInfo = new SQLGemInfo(); ItemSlot itemSlot = (ItemSlot)reader.GetInt16(ITEMSLOT_COLUMN); gemInfo.GemID1 = reader.GetInt32(GEMID1_COLUMN); gemInfo.GemID2 = reader.GetInt32(GEMID2_COLUMN); gemInfo.GemID3 = reader.GetInt32(GEMID3_COLUMN); gemInfo.GemID4 = reader.GetInt32(GEMID4_COLUMN); _ResultGearGems.Gems.Add(itemSlot, gemInfo); } return(true); } } } } finally { CloseConnection(); } _ResultGearGems = SQLPlayerGearGems.CreateEmpty(); return(false); }