Beispiel #1
0
        public static IAsyncEnumerable <IAdoNetStreamingResult> ExecuteSchemaResultsAsync(this IUnitOfWork unitOfWork, CommandType commandType, string commandText, IEnumerable <DbParameter> commandParameters, CancellationToken cancellationToken)
        {
            IAsyncEnumerable <IAdoNetStreamingResult> results;

            if ((object)unitOfWork == null)
            {
                throw new ArgumentNullException(nameof(unitOfWork));
            }

            results = AdoNetStreamingFascade.ExecuteSchemaResultsAsync(unitOfWork.Connection, unitOfWork.Transaction, commandType, commandText, commandParameters, cancellationToken);

            return(results);
        }
Beispiel #2
0
        /// <summary>
        /// An extension method to create a new data parameter from the data source.
        /// </summary>
        /// <param name="unitOfWork"> The target unit of work. </param>
        /// <param name="columnSource"> Specifies the column source. </param>
        /// <param name="parameterDirection"> Specifies the parameter direction. </param>
        /// <param name="dbType"> Specifies the parameter provider-(in)dependent type. </param>
        /// <param name="parameterSize"> Specifies the parameter size. </param>
        /// <param name="parameterPrecision"> Specifies the parameter precision. </param>
        /// <param name="parameterScale"> Specifies the parameter scale. </param>
        /// <param name="parameterNullable"> Specifies the parameter nullable-ness. </param>
        /// <param name="parameterName"> Specifies the parameter name. </param>
        /// <param name="parameterValue"> Specifies the parameter value. </param>
        /// <returns> The data parameter with the specified properties set. </returns>
        public static DbParameter CreateParameter(this IUnitOfWork unitOfWork, string columnSource, ParameterDirection parameterDirection, DbType dbType, int parameterSize, byte parameterPrecision, byte parameterScale, bool parameterNullable, string parameterName, object parameterValue)
        {
            DbParameter dbParameter;

            if ((object)unitOfWork == null)
            {
                throw new ArgumentNullException(nameof(unitOfWork));
            }

            dbParameter = AdoNetStreamingFascade.CreateParameter(unitOfWork.Connection, unitOfWork.Transaction, columnSource, parameterDirection, dbType, parameterSize, parameterPrecision, parameterScale, parameterNullable, parameterName, parameterValue);

            return(dbParameter);
        }
Beispiel #3
0
        public static IAsyncEnumerable <IPayload> ExecuteRecordsAsync(this IUnitOfWork unitOfWork, CommandType commandType, string commandText, IEnumerable <DbParameter> commandParameters, Action <int> rowsAffectedCallback, CancellationToken cancellationToken)
        {
            IAsyncEnumerable <IPayload> records;

            if ((object)unitOfWork == null)
            {
                throw new ArgumentNullException(nameof(unitOfWork));
            }

            // DO NOT DISPOSE OF DATA READER HERE - THE YIELD STATE MACHINE BELOW WILL DO THIS
            records = AdoNetStreamingFascade.ExecuteRecordsAsync(unitOfWork.Connection, unitOfWork.Transaction, commandType, commandText, commandParameters, rowsAffectedCallback, cancellationToken);

            return(records);
        }
Beispiel #4
0
        /// <summary>
        /// An extension method to execute a result query operation against a target unit of work.
        /// DO NOT DISPOSE OF UNIT OF WORK CONTEXT - UP TO THE CALLER.
        /// </summary>
        /// <param name="unitOfWork"> The target unit of work. </param>
        /// <param name="commandType"> The type of the command. </param>
        /// <param name="commandText"> The SQL text or stored procedure name. </param>
        /// <param name="commandParameters"> The parameters to use during the operation. </param>
        /// <returns> An enumerable of result instances, each containing an enumerable of records with (key/value pairs of data). </returns>
        public static IEnumerable <IAdoNetStreamingResult> ExecuteResults(this IUnitOfWork unitOfWork, CommandType commandType, string commandText, IEnumerable <DbParameter> commandParameters)
        {
            IEnumerable <IAdoNetStreamingResult> results;

            if ((object)unitOfWork == null)
            {
                throw new ArgumentNullException(nameof(unitOfWork));
            }

            // DO NOT DISPOSE OF DATA READER HERE - THE YIELD STATE MACHINE BELOW WILL DO THIS
            results = AdoNetStreamingFascade.ExecuteResults(unitOfWork.Connection, unitOfWork.Transaction, commandType, commandText, commandParameters);

            return(results);
        }