Exemple #1
0
        public IEnumerable <TResult> Stream <TResult>(string query, CommandParameterValues args, Func <IProjectionMapper, TResult> projectionMapper, TimeSpan?commandTimeout = null)
        {
            var command = new PreparedCommand(query, args, RetriableOperation.Select, commandBehavior: CommandBehavior.Default, commandTimeout: commandTimeout);

            using var reader = ExecuteReader(command);
            var mapper = new ProjectionMapper(command, reader, configuration.ReaderStrategies);

            while (reader.Read())
            {
                yield return(projectionMapper(mapper));
            }
        }
Exemple #2
0
        public async IAsyncEnumerable <TResult> StreamAsync <TResult>(string query, CommandParameterValues args, Func <IProjectionMapper, TResult> projectionMapper, TimeSpan?commandTimeout = null, [EnumeratorCancellation] CancellationToken cancellationToken = default)
        {
            var command = new PreparedCommand(query, args, RetriableOperation.Select, commandBehavior: CommandBehavior.Default, commandTimeout: commandTimeout);

            await using var reader = await ExecuteReaderAsync(command, cancellationToken);

            var mapper = new ProjectionMapper(command, reader, configuration.ReaderStrategies);

            while (await reader.ReadAsync(cancellationToken))
            {
                yield return(projectionMapper(mapper));
            }
        }