/// <summary> /// Executes the command against the connection and sends the resulting <see cref="IDataQueryAsync" /> for reading multiple results sets. /// </summary> /// <param name="queryAction">The query action delegate to pass the open <see cref="IDataQueryAsync" /> for reading multiple results.</param> /// <param name="cancellationToken">The cancellation instruction.</param> public async Task QueryMultipleAsync(Action <IDataQueryAsync> queryAction, CancellationToken cancellationToken = default(CancellationToken)) { if (queryAction == null) { throw new ArgumentNullException(nameof(queryAction)); } AssertDisposed(); try { await _dataSession.EnsureConnectionAsync(cancellationToken).ConfigureAwait(false); LogCommand(); using (var reader = await _command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false)) { var query = new QueryMultipleResult(reader); queryAction(query); } TriggerCallbacks(); } finally { _dataSession.ReleaseConnection(); Dispose(); } }
/// <summary> /// Executes the command against the connection and sends the resulting <see cref="IDataQuery" /> for reading multiple results sets. /// </summary> /// <param name="queryAction">The query action delegate to pass the open <see cref="IDataQuery" /> for reading multiple results.</param> public void QueryMultiple(Action <IDataQuery> queryAction) { if (queryAction == null) { throw new ArgumentNullException(nameof(queryAction)); } AssertDisposed(); try { _dataSession.EnsureConnection(); LogCommand(); using (var reader = _command.ExecuteReader()) { var query = new QueryMultipleResult(reader); queryAction(query); } TriggerCallbacks(); } finally { _dataSession.ReleaseConnection(); Dispose(); } }
/// <summary> /// Executes the command against the connection and sends the resulting <see cref="IDataQueryAsync" /> for reading multiple results sets. /// </summary> /// <param name="queryAction">The query action delegate to pass the open <see cref="IDataQueryAsync" /> for reading multiple results.</param> /// <param name="cancellationToken">The cancellation instruction.</param> public async Task QueryMultipleAsync(Action <IDataQueryAsync> queryAction, CancellationToken cancellationToken = default) { if (queryAction == null) { throw new ArgumentNullException(nameof(queryAction)); } await QueryFactoryAsync(async (token) => { using var reader = await _command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false); var query = new QueryMultipleResult(reader); queryAction(query); return(true); }, false, cancellationToken).ConfigureAwait(false); }
/// <summary> /// Executes the command against the connection and sends the resulting <see cref="IDataQuery" /> for reading multiple results sets. /// </summary> /// <param name="queryAction">The query action delegate to pass the open <see cref="IDataQuery" /> for reading multiple results.</param> public void QueryMultiple(Action <IDataQuery> queryAction) { if (queryAction == null) { throw new ArgumentNullException(nameof(queryAction)); } QueryFactory(() => { using var reader = _command.ExecuteReader(); var query = new QueryMultipleResult(reader); queryAction(query); return(true); }, false); }