Example #1
0
        /// <summary>
        /// 返回受影响行数
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public async Task <int> ExecuteNonQuery(DbConnection conn, string sql, DbTransaction tran = null)
        {
            int Rows = 0;

            await CommonExecute <object>(conn, sql, async (ClientDbCommand) => {
                Rows = await ClientDbCommand.ExecuteNonQueryAsync();
            }, null, tran);

            return(Rows);
        }
Example #2
0
        /// <summary>
        /// 新增返回主键
        /// </summary>
        /// <typeparam name="TParamter"></typeparam>
        /// <param name="conn"></param>
        /// <param name="sql"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task <long> ExecuteNonQueryByKey <TParamter>(DbConnection conn, string sql, TParamter parameters, DbTransaction tran = null) where TParamter : class
        {
            long IdentityId = 0;

            await CommonExecute(conn, sql, async (ClientDbCommand) => {
                await ClientDbCommand.ExecuteNonQueryAsync();
                IdentityId = ClientDbCommand.LastInsertedId;
            }, parameters, tran);

            return(IdentityId);
        }
Example #3
0
        /// <summary>
        /// 返回受影响行数
        /// </summary>
        /// <typeparam name="TParamter"></typeparam>
        /// <param name="conn"></param>
        /// <param name="sql"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task <int> ExecuteNonQuery <TParamter>(DbConnection conn, string sql, TParamter parameters, DbTransaction tran = null)
            where TParamter : class
        {
            int Rows = 0;

            await CommonExecute(conn, sql, async (ClientDbCommand) => {
                Rows = await ClientDbCommand.ExecuteNonQueryAsync();
            }, parameters, tran);

            return(Rows);
        }
Example #4
0
        /// <summary>
        /// 新增返回主键
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public async Task <long> ExecuteNonQueryByKey(DbConnection conn, string sql, DbTransaction tran = null)
        {
            long IdentityId = 0;

            await CommonExecute(conn, sql, async (ClientDbCommand) => {
                await ClientDbCommand.ExecuteNonQueryAsync();
                IdentityId = ClientDbCommand.LastInsertedId;
            }, tran);

            return(IdentityId);
        }