Exemplo n.º 1
0
        /// <summary>
        /// Inserts a new record into the table.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="tableName">Name of the table to insert into.</param>
        /// <param name="values">The values that will be added to the table. Can be anything that can be converted to a property bag.</param>
        /// <returns>The newly inserted row.</returns>
        public async static Task <dynamic> InsertAsync(this BaDatabase db, string tableName, object values)
        {
            var conn = await db.GetConnectionAsync().ConfigureAwait(false);

            var cmd = conn.CreateCommand();

            PrepareInsertCmd(cmd, tableName, values);
            return(await db.GetDynamicAsync(cmd).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the first row as a dynamic object.
        /// </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 async static Task <dynamic> GetDynamicAsync(this BaDatabase db, string sprocName, object parameters = null)
        {
            var cmd = await db.PrepareSprocCmdAsync(sprocName, parameters).ConfigureAwait(false);

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