Class QueryExectionExtensions
Inheritance
QueryExectionExtensions
Assembly: SoDataBase.dll
Syntax
public static class QueryExectionExtensions
Methods
ExecuteBatchedReaderAsync(SqlCommand, bool, int, CancellationToken)
Execute a SELECT statement in batches against the database and return the results as an IAsyncEnumerable, suitable for linq expressions and iteration.
This is a specialized method intended for very long-running queries (> 60 minutes). Use with care, when needed!
Declaration
public static IAsyncEnumerable<ISoDataRecord> ExecuteBatchedReaderAsync(this SqlCommand command, bool ignoreSentry = false, int batchSize = 20000, CancellationToken cancellationToken = default)
Parameters
| Type |
Name |
Description |
| SqlCommand |
command |
The SELECT query to execute in batches. Must be a PrivateSelect
with no RightOuterJoin restrictions and no Aggregation return fields.
|
| bool |
ignoreSentry |
Whether to ignore sentry when executing the batch queries.
|
| int |
batchSize |
Maximum number of rows per batch (default 20,000). Actual batch size may exceed
this value when ordering by a non-PK field, as the boundary aligns with value changes.
|
| CancellationToken |
cancellationToken |
Cancellation token, passed down to the database server.
|
Returns
Remarks
ExecuteNonQuery(SqlCommand)
Declaration
public static int ExecuteNonQuery(this SqlCommand command)
Parameters
Returns
ExecuteNonQueryAsync(SqlCommand, CancellationToken)
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<int> ExecuteNonQueryAsync(this SqlCommand command, CancellationToken cancellationToken = default)
Parameters
Returns
ExecuteReader(SqlCommand, bool)
Execute a SELECT statement against the database and return the results as an IAsyncEnumerable, suitable for linq expressions and iteration.
But please DON'T use the anti-pattern 'fetch everything then post-filter using Linq'; put all the restrictions you can
into the select before Fetch'ing the results.
Declaration
public static IEnumerable<ISoDataRecord> ExecuteReader(this SqlCommand command, bool ignoreSentry = false)
Parameters
| Type |
Name |
Description |
| SqlCommand |
command |
An SqlCommand that is a select
|
| bool |
ignoreSentry |
|
Returns
| Type |
Description |
| IEnumerable<ISoDataRecord> |
Enumerable result, which contains FieldInfo-based Get methods for all common data types
|
ExecuteReaderAsync(SqlCommand, bool, CancellationToken)
Execute a SELECT statement against the database and return the results as an IAsyncEnumerable, suitable for linq expressions and iteration.
But please DON'T use the anti-pattern 'fetch everything then post-filter using Linq'; put all the restrictions you can
into the select before Fetch'ing the results.
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static IAsyncEnumerable<ISoDataRecord> ExecuteReaderAsync(this SqlCommand command, bool ignoreSentry = false, CancellationToken cancellationToken = default)
Parameters
Returns
ExecuteScalarAsync<T>(SqlCommand, bool, CancellationToken)
Declaration
public static Task<T> ExecuteScalarAsync<T>(this SqlCommand command, bool ignoreSentry, CancellationToken cancellationToken = default)
Parameters
Returns
Type Parameters
ExecuteScalarAsync<T>(SqlCommand, CancellationToken)
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<T> ExecuteScalarAsync<T>(this SqlCommand command, CancellationToken cancellationToken = default)
Parameters
Returns
Type Parameters
ExecuteScalar<T>(SqlCommand)
Declaration
public static T ExecuteScalar<T>(this SqlCommand command)
Parameters
Returns
Type Parameters
GetFieldPropertyRead(QueryExecutionHelper, FieldInfo)
Declaration
public static FieldProperty GetFieldPropertyRead(this QueryExecutionHelper qeh, FieldInfo field)
Parameters
Returns