Example #1
0
 public static int EFDelete <T>(this MySqlConnection connection, T instance, string table)
 {
     using (var cmd = EntityCommandBuilder.BuildDeleteCommand(instance, table, connection))
     {
         return(cmd.ExecuteNonQuery());
     }
 }
Example #2
0
 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());
     }
 }
Example #3
0
 /// <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();
     }
 }
Example #4
0
 /// <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();
             }
         }
     }
 }