public static int EFUpdate <T>(this MySqlConnection connection, T instance, string table) { using (var cmd = EntityCommandBuilder.BuildUpdateCommand(instance, table, connection)) { return(cmd.ExecuteNonQuery()); } }
public static async Task <int> EFUpdateAsync <T>(this MySqlConnection connection, T instance, string table) { using (var cmd = EntityCommandBuilder.BuildUpdateCommand(instance, table, connection)) { return(await cmd.ExecuteNonQueryAsync()); } }
/// <summary> /// Updates an object in the specified database table. Object Model must have an associated Primary Key. /// </summary> public async Task UpdateAsync <T>(T Obj, string Table) { using (MySqlConnection Connection = GetConnection(autoOpen: false, forceNew: true)) { await Connection.OpenAsync(); using (MySqlCommand Command = EntityCommandBuilder.BuildUpdateCommand <T>(Obj, Table, Connection)) { await Command.ExecuteNonQueryAsync(); } } }
/// <summary> /// Updates an object in the specified database table. Object Model must have an associated Primary Key. /// </summary> public void Update <T>(T Obj, string Table) { if (ReuseSingleConnection) { lock (ActiveConnection) { using (MySqlCommand Command = EntityCommandBuilder.BuildUpdateCommand <T>(Obj, Table, ActiveConnection)) { Command.ExecuteNonQuery(); } } } else { using (MySqlConnection Connection = GetConnection(autoOpen: true, forceNew: true)) { using (MySqlCommand Command = EntityCommandBuilder.BuildUpdateCommand <T>(Obj, Table, Connection)) { Command.ExecuteNonQuery(); } } } }