public void Create(IDomain o) { UserEntity u = (UserEntity)o; var cmd = (MySqlCommand)Connection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT INTO users (name, sys_id) VALUES (@name, @sysid)"; cmd.Parameters.AddWithValue("@name", u.Name); cmd.Parameters.AddWithValue("@sysid", u.GetId()); cmd.ExecuteScalar(); }
public IDomain Read(string ID) { var buf = new UserEntity(); var cmd = Connection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT * FROM users WHERE sys_id = '" + ID + "';"; var reader = cmd.ExecuteReader(); while (reader.Read()) { buf.SetId(reader.GetString(3)); buf.Name = reader.GetString(2); } reader.Close(); Connection.Close(); return(buf); }