示例#1
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) => {
                IdentityId = Convert.ToInt64(await ClientDbCommand.ExecuteScalarAsync());
            }, parameters, tran);

            return(IdentityId);
        }
示例#2
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) => {
                IdentityId = Convert.ToInt64(await ClientDbCommand.ExecuteScalarAsync());
            }, tran);

            return(IdentityId);
        }