Exemplo n.º 1
0
        /// <summary>
        /// Deletes the records with the given key.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="tableName">Name of the table to remove records from.</param>
        /// <param name="key">Key of the record to delete. Can be anything that can be converted to a property bag.</param>
        /// <returns></returns>
        public async static Task <int> DeleteAsync(this BaDatabase db, string tableName, object key)
        {
            var conn = await db.GetConnectionAsync();

            var cmd = conn.CreateCommand();

            PrepareDeleteCmd(cmd, tableName, key);
            return(await db.ExecuteNonQueryAsync(cmd).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes a Transact-SQL statement against the connection and returns the number
        /// of rows affected.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="sprocName">Name of the stored procedure to call.</param>
        /// <param name="parameters">An object that contains the properties to add as SQL parameters to the SQL command.</param>
        /// <returns></returns>
        public static async Task <int> ExecuteNonQueryAsync(this BaDatabase db, string sprocName, object parameters = null)
        {
            var cmd = db.PrepareSprocCmd(sprocName, parameters);

            return(await db.ExecuteNonQueryAsync(cmd).ConfigureAwait(false));
        }