diff --git a/Source/Core/MappedDbQuery.cs b/Source/Core/MappedDbQuery.cs index de30a8c6..ecd0a21f 100644 --- a/Source/Core/MappedDbQuery.cs +++ b/Source/Core/MappedDbQuery.cs @@ -68,11 +68,8 @@ internal MappedDbQuery(DbQuery definition, IRowSource source) public MappedDbQuery SingleResult() => new( - Query, - _source, - _options | QueryOptions.SingleResult, - _pool, - _clearOnReturn); + Query, _source, _options | QueryOptions.SingleResult, + _pool, _clearOnReturn); /// /// Cancels the command when a terminal stops before the last row, in every query made from this definition @@ -82,11 +79,8 @@ public MappedDbQuery SingleResult() /// public MappedDbQuery CancelOnEarlyStop() => new( - Query, - _source, - _options | QueryOptions.CancelOnEarlyStop, - _pool, - _clearOnReturn); + Query, _source, _options | QueryOptions.CancelOnEarlyStop, + _pool, _clearOnReturn); /// /// Reads the rows with the asynchronous read of the provider, in every query made from this definition @@ -96,11 +90,8 @@ public MappedDbQuery CancelOnEarlyStop() /// public MappedDbQuery AsyncReads() => new( - Query, - _source, - _options | QueryOptions.AsyncReads, - _pool, - _clearOnReturn); + Query, _source, _options | QueryOptions.AsyncReads, + _pool, _clearOnReturn); /// /// Asks the reader for sequential access, in every query made from this definition @@ -110,11 +101,8 @@ public MappedDbQuery AsyncReads() /// public MappedDbQuery SequentialAccess() => new( - Query, - _source, - _options | QueryOptions.SequentialAccess, - _pool, - _clearOnReturn); + Query, _source, _options | QueryOptions.SequentialAccess, + _pool, _clearOnReturn); /// /// Returns a definition whose switches, in every query made from it, are @@ -124,11 +112,8 @@ public MappedDbQuery SequentialAccess() /// A definition with exactly these switches. public MappedDbQuery WithOptions(QueryOptions options) => new( - Query, - _source, - Views.CheckedOptions(options), - _pool, - _clearOnReturn); + Query, _source, Views.CheckedOptions(options), + _pool, _clearOnReturn); /// /// Takes the arrays that hold the rows from , in every query made from this definition diff --git a/Source/Core/MappedQuery.Capture.cs b/Source/Core/MappedQuery.Capture.cs index 6a1564f2..19c3c7b0 100644 --- a/Source/Core/MappedQuery.Capture.cs +++ b/Source/Core/MappedQuery.Capture.cs @@ -52,18 +52,10 @@ public MappedQueryCore WithCapture(ICaptureSource source) // first capture, and one run claims them. CaptureSet captures = CaptureSet.With( _captures as CaptureSet ?? runner.Captures, - source, - onQuery: true, - runner.IsProcedure); + source, onQuery: true, runner.IsProcedure); return new( - _command, - _call, - _source, - _skip, - _take, - Options, - Config, - captures); + _command, _call, _source, + _skip, _take, Options, Config, captures); } /// @@ -74,14 +66,8 @@ public MappedQueryCore WithCapture(ICaptureSource source) /// The query for the stream or the buffer to read. MappedQueryCore WithRun(CaptureRun run) => new( - _command, - _call, - _source, - _skip, - _take, - Options, - Config, - run); + _command, _call, _source, + _skip, _take, Options, Config, run); /// /// Makes the run of a stream, claimed later by its diff --git a/Source/Core/MappedQuery.cs b/Source/Core/MappedQuery.cs index 31e40706..05865a93 100644 --- a/Source/Core/MappedQuery.cs +++ b/Source/Core/MappedQuery.cs @@ -296,14 +296,8 @@ CommandBehavior Behavior /// A copy of the query with . public MappedQueryCore WithOptions(QueryOptions options) => Checked(new( - _command, - _call, - _source, - _skip, - _take, - options, - Config, - _captures)); + _command, _call, _source, + _skip, _take, options, Config, _captures)); /// /// Returns the query with one more switch set, and the others as they were. @@ -334,11 +328,8 @@ public MappedQueryCore WithPool(ArrayPool pool, bool clearOnReturn) // The pool is the caller's; the sizes and the bin stay what the query had. return WithConfig(new ChunkConfig( - pool, - clearOnReturn, - Config.Sizes, - Config.Bin, - Config.DeferFromClearedBytes)); + pool, clearOnReturn, + Config.Sizes, Config.Bin, Config.DeferFromClearedBytes)); } /// @@ -349,14 +340,8 @@ public MappedQueryCore WithPool(ArrayPool pool, bool clearOnReturn) /// A copy of the query that uses . public MappedQueryCore WithConfig(ChunkConfig config) => Checked(new( - _command, - _call, - _source, - _skip, - _take, - Options, - config, - _captures)); + _command, _call, _source, + _skip, _take, Options, config, _captures)); /// Returns the same query over another call. /// The query carries a capture, @@ -370,14 +355,8 @@ public MappedQueryCore WithCall(DbQueryCall call) public MappedQueryCore WithSkip(int count) => count >= 0 ? Checked(new( - _command, - _call, - _source, - _skip + count, - _take, - Options, - Config, - _captures)) + _command, _call, _source, + _skip + count, _take, Options, Config, _captures)) : throw new ArgumentOutOfRangeException(nameof(count), count, "Cannot be negative."); /// @@ -391,14 +370,8 @@ public MappedQueryCore WithSkip(int count) public MappedQueryCore WithTake(int count) => count >= 0 ? Checked(new( - _command, - _call, - _source, - _skip, - count, - Options, - Config, - _captures)) + _command, _call, _source, + _skip, count, Options, Config, _captures)) : throw new ArgumentOutOfRangeException(nameof(count), count, "Cannot be negative."); /// @@ -527,11 +500,7 @@ TResult ExecuteReader(TState state, Func ExecuteReaderAsync(TState state, Func> transform, CommandBehavior behavior, CancellationToken token) => Captured() is { } captures ? ((ICaptureRunner)_command!).ExecuteReaderAsync( - captures, - state, - transform, - behavior, - token) + captures, state, transform, behavior, token) : _call.IsBound ? _call.RunAsync(state, transform, behavior, token) : Command.ExecuteReaderAsync(state, transform, behavior, token); @@ -582,12 +551,8 @@ public void Read(Action> handler) static (reader, s) => { s.handler(RowReader.Stream( - s._source, - reader, - s._skip, - s._take, - !s.SingleResult, - s.abandon)); + s._source, reader, s._skip, s._take, + !s.SingleResult, s.abandon)); return false; }, Behavior, @@ -628,14 +593,8 @@ static async (reader, s) => { await s.handler( StreamAsync( - s._source, - reader, - s._skip, - s._take, - s.SingleResult, - s.AsyncReads, - s.abandon, - s.token), + s._source, reader, s._skip, s._take, + s.SingleResult, s.AsyncReads, s.abandon, s.token), s.token).ConfigureAwait(false); return false; }, @@ -850,24 +809,14 @@ static async (reader, s) => if (reader is DbDataReader db) { (bool found, T? item) = await RowReader.TryFirstAsync( - s._source, - db, - s._skip, - s._take, - s.AsyncReads, - s.token, - s.abandon).ConfigureAwait(false); + s._source, db, s._skip, s._take, + s.AsyncReads, s.token, s.abandon).ConfigureAwait(false); return found ? item : default; } return RowReader.TryFirst( - s._source, - reader, - s._skip, - s._take, - out T? i, - s.abandon, - s.token) + s._source, reader, s._skip, s._take, + out T? i, s.abandon, s.token) ? i : default; }, @@ -888,24 +837,14 @@ static async (reader, s) => if (reader is DbDataReader db) { (bool found, T? item) = await RowReader.TrySingleAsync( - s._source, - db, - s._skip, - s._take, - s.AsyncReads, - s.token, - s.abandon).ConfigureAwait(false); + s._source, db, s._skip, s._take, + s.AsyncReads, s.token, s.abandon).ConfigureAwait(false); return found ? item : default; } return RowReader.TrySingle( - s._source, - reader, - s._skip, - s._take, - out T? i, - s.abandon, - s.token) + s._source, reader, s._skip, s._take, + out T? i, s.abandon, s.token) ? i : default; }, @@ -1192,8 +1131,7 @@ public IAsyncEnumerable ToPooledStream( IAsyncEnumerable rows = Flatten( new ChunkStream( run is null ? this : WithRun(run), - Config, - cancellationToken), + Config, cancellationToken), CancellationToken.None); // Captured: the claim is at the flattened stream's GetAsyncEnumerator. @@ -1259,10 +1197,7 @@ IAsyncEnumerable StreamCore( return bufferSize == 0 ? new DirectStream(this, stallTimeout, cancellationToken) : new StallStream( - this, - stallTimeout, - bufferSize, - cancellationToken); + this, stallTimeout, bufferSize, cancellationToken); } CaptureRun run = StreamRun(captures, cancellationToken); @@ -1271,10 +1206,7 @@ IAsyncEnumerable StreamCore( bufferSize == 0 ? new DirectStream(claimed, stallTimeout, cancellationToken) : new StallStream( - claimed, - stallTimeout, - bufferSize, - cancellationToken), + claimed, stallTimeout, bufferSize, cancellationToken), run); } diff --git a/Source/Core/MappedViews.cs b/Source/Core/MappedViews.cs index 1273c229..e3dcdf48 100644 --- a/Source/Core/MappedViews.cs +++ b/Source/Core/MappedViews.cs @@ -345,9 +345,7 @@ DbQueryCall call DbQueryUsing bound => NewCore(null, bound.ToCall(), source, Single(singleResult)), _ => NewCore( - command, - default, - source, + command, default, source, Single(singleResult) | (AsyncReads(command) ? QueryOptions.AsyncReads @@ -367,9 +365,7 @@ internal static MappedQueryCore ReaderCore( IDataReader reader, IRowSource source) => NewCore( - new ReaderExecutor(reader), - default, - source, + new ReaderExecutor(reader), default, source, QueryOptions.SingleResult); internal static MappedQueryCore CommandCore( @@ -377,23 +373,17 @@ internal static MappedQueryCore CommandCore( IRowSource source) => command is SingleResultDbCommand single ? NewCore( - new CommandExecutor(single.Command), - default, - source, + new CommandExecutor(single.Command), default, source, QueryOptions.SingleResult) : NewCore( - new CommandExecutor(command), - default, - source, + new CommandExecutor(command), default, source, QueryOptions.None); internal static MappedQueryCore TableCore( DataTable table, IRowSource source) => NewCore( - new TableExecutor(table), - default, - source, + new TableExecutor(table), default, source, QueryOptions.SingleResult); ///