public static int EFDelete <T>(this MySqlConnection connection, T instance, string table) { using (var cmd = EntityCommandBuilder.BuildDeleteCommand(instance, table, connection)) { return(cmd.ExecuteNonQuery()); } }
public static async Task <int> EFDeleteAsync <T>(this MySqlConnection connection, T instance, string table) { using (var cmd = EntityCommandBuilder.BuildDeleteCommand(instance, table, connection)) { return(await cmd.ExecuteNonQueryAsync()); } }
/// <summary> /// Deletes the object from a database table. Object Model must have an associated Primary Key. /// </summary> public async Task DeleteAsync <T>(T Obj, string Table) { using (MySqlConnection Connection = GetConnection(autoOpen: false, forceNew: true)) { Connection.Open(); using (MySqlCommand Command = EntityCommandBuilder.BuildDeleteCommand <T>(Obj, Table, Connection)) { await Command.ExecuteNonQueryAsync(); } Connection.Close(); } }
/// <summary> /// Deletes the object from a database table. Object Model must have an associated Primary Key. /// </summary> public void Delete <T>(T Obj, string Table) { if (ReuseSingleConnection) { lock (ActiveConnection) { using (MySqlCommand Command = EntityCommandBuilder.BuildDeleteCommand <T>(Obj, Table, ActiveConnection)) { Command.ExecuteNonQuery(); } } } else { using (MySqlConnection Connection = new MySqlConnection(ConnectionString)) { Connection.Open(); using (MySqlCommand Command = EntityCommandBuilder.BuildDeleteCommand <T>(Obj, Table, Connection)) { Command.ExecuteNonQuery(); } } } }