public static async Task <Dictionary <int, DB_Creature> > SelectAllCreaturesAsync() { try { using (var connection = await GetConnectionAsync()) { using (var command = connection.CreateCommand()) { command.CommandText = $"SELECT * FROM {tb_07};"; using (var reader = await command.ExecuteReaderAsyncEx()) { var result = new Dictionary <int, DB_Creature>(); if (reader.HasRows) { while (await reader.ReadAsyncEx()) { var id = reader.GetInt32(0); result[id] = new DB_Creature(id, reader.GetInt32(1), reader.GetByte(2), reader.GetInt32(3), reader.GetFloat(4), reader.GetInt32(5), reader.GetUInt16(6), reader.GetFloat(7), reader.GetFloat(8), reader.GetFloat(9), reader.GetFloat(10), reader.GetFloat(11), reader.GetFloat(12), reader.GetFloat(13), reader.GetFloat(14), reader.GetFloat(15), reader.GetFloat(16), reader.GetFloat(17)); } } return(result); } } } } catch (Exception exp) { ServerLogger.LogException(exp); return(null); } }
public static bool SelectAllCreatures(out Dictionary <int, DB_Creature> data) { var locked = false; data = new Dictionary <int, DB_Creature>(); if (!IsConnected) { return(false); } try { using (MySqlCommand _cmd = _connection.CreateCommand()) { _cmd.CommandText = $"SELECT * FROM {tb_07};"; Monitor.Enter(s_lock, ref locked); using (MySqlDataReader _result = _cmd.ExecuteReader()) { int id; if (_result.HasRows) { while (_result.Read()) { id = _result.GetInt32(0); data[id] = new DB_Creature(id, _result.GetInt32(1), _result.GetByte(2), _result.GetInt32(3), _result.GetFloat(4), _result.GetInt32(5), _result.GetUInt16(6), _result.GetFloat(7), _result.GetFloat(8), _result.GetFloat(9), _result.GetFloat(10), _result.GetFloat(11), _result.GetFloat(12), _result.GetFloat(13), _result.GetFloat(14), _result.GetFloat(15), _result.GetFloat(16), _result.GetFloat(17)); } } } } return(true); } catch { return(false); } finally { if (locked) { Monitor.Exit(s_lock); } } }
public static bool Select(int id, out DB_Creature entry) { return(m_creatures.TryGetValue(id, out entry)); }