コード例 #1
0
        /// <summary>
        /// 查询,返回DataTable结果集
        /// </summary>
        /// <param name="commandText">SQL语句</param>
        /// <param name="commandParameters">参数集合</param>
        /// <param name="commandType">SQL语句 | 存储过程</param>
        /// <param name="connectionAliasName">连接别名;如果没起别名,则使用默认的连接字符串</param>
        /// <returns>DataTable结果集</returns>
#else
        /// <summary>
        /// async Query,Get result of DataTable
        /// </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>DataTable</returns>
#endif
        public static async Task <DataTable> ExecuteDataTableAsync(string commandText, SqlParameter[] commandParameters, string connectionAliasName = ALIAS_NAME_DEFAULT, CommandType commandType = CommandType.Text)
        {
            DataSet ds = await AsyncSQLHelper.ExecuteDatasetAsync(GetConnection(connectionAliasName), commandType, commandText, commandParameters);

            //返回结果
            if (ds == null || ds.Tables == null || ds.Tables.Count <= 0)
            {
                return(null);
            }
            return(ds.Tables[0]);
        }
コード例 #2
0
        /// <summary>
        /// 异步查询,返回DataTable结果集
        /// </summary>
        /// <param name="commandText">SQL语句</param>
        /// <param name="commandParameters">参数集合</param>
        /// <param name="transaction">使用指定的事务处理</param>
        /// <param name="commandType">SQL语句 | 存储过程</param>
        /// <returns>DataTable结果集</returns>
#else
        /// <summary>
        /// async Query,Get result of DataTable
        /// </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>DataTable</returns>
#endif
        public static async Task <DataTable> ExecuteDataTableAsync(string commandText, SqlParameter[] commandParameters, MicroDBTransaction transaction, CommandType commandType = CommandType.Text)
        {
            DataSet ds = await AsyncSQLHelper.ExecuteDatasetAsync(transaction.tran, commandType, commandText, commandParameters);

            //返回结果
            if (ds == null || ds.Tables == null || ds.Tables.Count <= 0)
            {
                return(null);
            }
            return(ds.Tables[0]);
        }
コード例 #3
0
ファイル: MicroDBHelper.cs プロジェクト: zxbe/MicroDBHelper
        /// <summary>
        /// 查询,返回DataSet结果集
        /// </summary>
        /// <param name="commandText">SQL语句</param>
        /// <param name="commandParameters">参数集合</param>
        /// <param name="commandType">SQL语句 | 存储过程</param>
        /// <param name="connectionAliasName">连接别名;如果没起别名,则使用默认的连接字符串</param>
        /// <returns>DataSet结果集</returns>
#else
        /// <summary>
        /// async Query,Get result of DataSet
        /// </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>DataSet</returns>
#endif
        public static async Task <DataSet> ExecuteDataSetAsync(string commandText, SqlParameter[] commandParameters, string connectionAliasName = ALIAS_NAME_DEFAULT, CommandType commandType = CommandType.Text)
        {
            DataSet ds = await AsyncSQLHelper.ExecuteDatasetAsync(GetConnection(connectionAliasName), commandType, commandText, commandParameters);

            return(ds);
        }
コード例 #4
0
ファイル: MicroDBHelper.cs プロジェクト: zxbe/MicroDBHelper
        /// <summary>
        /// 异步查询,返回DataSet结果集
        /// </summary>
        /// <param name="commandText">SQL语句</param>
        /// <param name="commandParameters">参数集合</param>
        /// <param name="transaction">使用指定的事务处理</param>
        /// <param name="commandType">SQL语句 | 存储过程</param>
        /// <returns>DataSet结果集</returns>
#else
        /// <summary>
        /// async Query,Get result of DataSet
        /// </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>DataSet</returns>
#endif
        public static async Task <DataSet> ExecuteDataSetAsync(string commandText, SqlParameter[] commandParameters, MicroDBTransaction transaction, CommandType commandType = CommandType.Text)
        {
            DataSet ds = await AsyncSQLHelper.ExecuteDatasetAsync(transaction.tran, commandType, commandText, commandParameters);

            return(ds);
        }