Example #1
0
        /// <inheritdoc />
        public Task <IEnumerable <T> > ExecuteStoredProcedureAsync <T>(
            ICuriosityReadOnlyDataContext context,
            string procedureName,
            IDictionary <string, object>?parameters = null,
            int?commandTimeoutSec = null,
            bool ignoreNulls      = true,
            CancellationToken cancellationToken = default)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var connection = context.Connection;

            var dynamicParams = parameters?.ConvertToDynamicParameters(ignoreNulls);

            var commandDefinition = new CommandDefinition(
                procedureName,
                dynamicParams,
                commandTimeout: commandTimeoutSec,
                commandType: CommandType.StoredProcedure,
                cancellationToken: cancellationToken);

            return(connection.QueryAsync <T>(commandDefinition));
        }
Example #2
0
        /// <inheritdoc />
        public T QuerySingleOrDefault <T>(
            ICuriosityReadOnlyDataContext context,
            string sqlTemplate,
            IDictionary <string, object>?parameters = null,
            bool ignoreNulls      = false,
            int?commandTimeoutSec = null)
        {
            var dynamicParams = parameters?.ConvertToDynamicParameters(ignoreNulls);

            var connection = context.Connection;

            return(connection.QuerySingleOrDefault <T>(sqlTemplate, dynamicParams, commandTimeout: commandTimeoutSec));
        }
Example #3
0
        /// <inheritdoc />
        public Task <IEnumerable <T> > QueryManyAsync <T>(
            ICuriosityReadOnlyDataContext context,
            string sqlTemplate,
            object?parameters,
            int?commandTimeoutSec = null,
            CancellationToken cancellationToken = default)
        {
            var connection = context.Connection;

            var commandDefinition = new CommandDefinition(sqlTemplate, parameters, commandTimeout: commandTimeoutSec, cancellationToken: cancellationToken);

            return(connection.QueryAsync <T>(commandDefinition));
        }
Example #4
0
        /// <inheritdoc />
        public IEnumerable <T> QueryMany <T>(
            ICuriosityReadOnlyDataContext context,
            string sqlTemplate,
            IDictionary <string, object>?parameters = null,
            bool ignoreNulls      = false,
            int?commandTimeoutSec = null)
        {
            var dynamicParams = parameters?.ConvertToDynamicParameters(ignoreNulls);

            var connection = context.Connection;
            var result     = connection.Query <T>(sqlTemplate, dynamicParams, commandTimeout: commandTimeoutSec);

            return(result);
        }
Example #5
0
        /// <inheritdoc />
        public Task <IEnumerable <T> > QueryManyAsync <T>(
            ICuriosityReadOnlyDataContext context,
            string sqlTemplate,
            IDictionary <string, object>?parameters = null,
            bool ignoreNulls      = true,
            int?commandTimeoutSec = null,
            CancellationToken cancellationToken = default)
        {
            var dynamicParams = parameters?.ConvertToDynamicParameters(ignoreNulls);

            var commandDefinition = new CommandDefinition(sqlTemplate, dynamicParams, commandTimeout: commandTimeoutSec, cancellationToken: cancellationToken);

            var connection = context.Connection;

            return(connection.QueryAsync <T>(commandDefinition));
        }
Example #6
0
        /// <inheritdoc />
        public IEnumerable <T> ExecuteStoredProcedure <T>(
            ICuriosityReadOnlyDataContext context,
            string procedureName,
            IDictionary <string, object>?parameters = null,
            int?commandTimeoutSec = null,
            bool ignoreNulls      = true)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var connection = context.Connection;

            var dynamicParams = parameters?.ConvertToDynamicParameters(ignoreNulls);

            return(connection.Query <T>(
                       procedureName,
                       dynamicParams,
                       commandTimeout: commandTimeoutSec,
                       commandType: CommandType.StoredProcedure));
        }