Ejemplo n.º 1
0
        /// <summary>
        /// 异步查询,返回单一结果
        /// </summary>
        /// <param name="commandText">SQL语句</param>
        /// <param name="commandParameters">参数集合</param>
        /// <param name="transaction">使用指定的事务处理</param>
        /// <param name="commandType">SQL语句 | 存储过程</param>
        /// <returns>单一结果</returns>
#else
        /// <summary>
        /// async Query,Get result of One Object
        /// </summary>
        /// <param name="commandText">SQL statement</param>
        /// <param name="commandParameters">SqlParameter Collection</param>
        /// <param name="transaction">transaction</param>
        /// <param name="commandType">Text | StoredProcedure</param>
        /// <returns>Object</returns>
#endif
        public static async Task <object> ExecuteScalarAsync(string commandText, SqlParameter[] commandParameters, MicroDBTransaction transaction, CommandType commandType = CommandType.Text)
        {
            if (transaction == null)
            {
                throw new InvalidOperationException(ERRMSG_TRANSACTION_IS_NULL, new ArgumentNullException("transaction"));
            }

            return(await AsyncSQLHelper.ExecuteScalarAsync(transaction.tran, commandType, commandText, commandParameters));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 异步查询,返回单一结果
        /// </summary>
        /// <param name="commandText">SQL语句</param>
        /// <param name="commandParameters">参数集合</param>
        /// <param name="commandType">SQL语句 | 存储过程</param>
        /// <param name="connectionAliasName">连接别名;如果没起别名,则使用默认的连接字符串</param>
        /// <returns>单一结果</returns>
#else
        /// <summary>
        /// async Query,Get result of One Object
        /// </summary>
        /// <param name="commandText">SQL statement</param>
        /// <param name="commandParameters">SqlParameter Collection</param>
        /// <param name="commandType">Text | StoredProcedure</param>
        /// <param name="connectionAliasName">the Alias Name of Connection (if not pass name,it will use the DEFAULT name instead.)</param>
        /// <returns>Object</returns>
#endif
        public static async Task <object> ExecuteScalarAsync(string commandText, SqlParameter[] commandParameters, string connectionAliasName = ALIAS_NAME_DEFAULT, CommandType commandType = CommandType.Text)
        {
            return(await AsyncSQLHelper.ExecuteScalarAsync(GetConnection(connectionAliasName), commandType, commandText, commandParameters));
        }