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