public Dictionary <string, DTreasure> GetTreasureAttri() { NpgsqlConnection conn = new NpgsqlConnection(connStr); using (conn) { NpgsqlCommand objCommand = new NpgsqlCommand(GetTreasureAttriSQL, conn); conn.Open(); DbDataReader reader = objCommand.ExecuteReader(); Dictionary <string, DTreasure> result = new Dictionary <string, DTreasure>(); while (reader.Read()) { // read attributes of all the treasures DTreasure tmp = new DTreasure() { treasureId = reader.GetInt32(reader.GetOrdinal("treasureid")), mainType = reader.GetInt32(reader.GetOrdinal("maintype")), speed = reader.GetInt32(reader.GetOrdinal("speedvalue")), intelligence = reader.GetInt32(reader.GetOrdinal("intelligencevalue")), attack = reader.GetInt32(reader.GetOrdinal("attackvalue")), defense = reader.GetInt32(reader.GetOrdinal("defensevalue")) }; result.Add(reader.GetString(reader.GetOrdinal("name")).Trim(), tmp); } ; return(result); } }
public Treasure FromDTreasure(DTreasure dTreasure) { this.treasureId = dTreasure.treasureId; this.name = dTreasure.name; this.mainType = dTreasure.mainType; this.speed = dTreasure.speed; this.intelligence = dTreasure.intelligence; this.attack = dTreasure.attack; this.defense = dTreasure.defense; return(this); }
public DTreasure ToDTreasure() { DTreasure treasure = new DTreasure() { treasureId = this.treasureId, name = this.name, mainType = this.mainType, speed = this.speed, intelligence = this.intelligence, attack = this.attack, defense = this.defense }; return(treasure); }