public async Task ExecuteAsync(ISqlCommand command) { var formatted = command.Format(SqlFormat.MySql); using (var connection = Open()) { using (var sqlCommand = new MySqlCommand(formatted, connection)) { await sqlCommand.ExecuteNonQueryAsync(); } } }
public void Execute(ISqlCommand command) { var formatted = command.Format(SqlFormat.MySql); using (var connection = Open()) { using (var sqlCommand = new MySqlCommand(formatted, connection)) { sqlCommand.ExecuteNonQuery(); } } }
public async Task <T> ExecuteSingleAsync <T>(ISqlCommand <T> command) { var formatted = command.Format(SqlFormat.MySql); using (var connection = Open()) { using (var sqlCommand = new MySqlCommand(formatted, connection)) { using (var reader = await sqlCommand.ExecuteReaderAsync()) { var fields = new MySqlFields(reader); while (reader.Read()) { return(command.TranslateRow(fields)); } } } } return(default(T)); }
public IEnumerable <T> ExecuteRead <T>(ISqlCommand <T> command) { var formatted = command.Format(SqlFormat.MySql); using (var connection = Open()) { using (var sqlCommand = new MySqlCommand(formatted, connection)) { using (var reader = sqlCommand.ExecuteReader()) { var fields = new MySqlFields(reader); while (reader.Read()) { var row = command.TranslateRow(fields); if (row != null) { yield return(row); } } } } } }