public static List<Character> Retrieve(ulong uid) { DbConnection dbconn = Database.GetConnection(); DbCommand command = dbconn.CreateTextCommand("SELECT * FROM Characters WHERE UID = @uid"); command.AddParameter("@uid", uid); List<Character> chars = new List<Character>(); using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var character = new Character(); character.CID = Convert.ToUInt64(reader["CID"]); character.UID = Convert.ToUInt64(reader["UID"]); character.Name = reader["Name"] as string; character.Mito = Convert.ToInt64(reader["Mito"]); character.Avatar = Convert.ToInt32(reader["Avatar"]); character.Level = Convert.ToInt32(reader["Level"]); character.City = Convert.ToInt32(reader["City"]); character.CurrentCarID = Convert.ToInt32(reader["CurrentCarID"]); character.GarageLevel = Convert.ToInt32(reader["GarageLevel"]); character.TID = Convert.ToInt64(reader["TID"]); chars.Add(character); } } return chars; }
public static Character Retrieve(string charname) { DbConnection dbconn = Database.GetConnection(); DbCommand command = dbconn.CreateTextCommand("SELECT * FROM Characters WHERE Name = @char"); command.AddParameter("@char", charname); Character character = null; using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { character = new Character(); character.CID = Convert.ToUInt64(reader["CID"]); character.UID = Convert.ToUInt64(reader["UID"]); character.Name = reader["Name"] as string; character.Mito = Convert.ToInt64(reader["Mito"]); character.Avatar = Convert.ToInt32(reader["Avatar"]); character.Level = Convert.ToInt32(reader["Level"]); character.City = Convert.ToInt32(reader["City"]); character.CurrentCarID = Convert.ToInt32(reader["CurrentCarID"]); character.GarageLevel = Convert.ToInt32(reader["GarageLevel"]); character.TID = Convert.ToInt64(reader["TID"]); } } return character; }