Class DataQueryExtensions
- Namespace
- FluentCommand
- Assembly
- FluentCommand.dll
Extension methods for IDataQuery
public static class DataQueryExtensions
- Inheritance
-
DataQueryExtensions
- Inherited Members
Methods
Query(IDataQuery)
Executes the command against the connection and converts the results to dynamic objects.
public static IEnumerable<dynamic> Query(this IDataQuery dataQuery)
Parameters
dataQuery
IDataQueryThe IDataQuery for this extension method.
Returns
- IEnumerable<dynamic>
An IEnumerable<T> of dynamic objects.
QueryAsync(IDataQueryAsync, CancellationToken)
Executes the command against the connection and converts the results to dynamic objects asynchronously.
public static Task<IEnumerable<dynamic>> QueryAsync(this IDataQueryAsync dataQuery, CancellationToken cancellationToken = default)
Parameters
dataQuery
IDataQueryAsyncThe IDataQueryAsync for this extension method.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task<IEnumerable<dynamic>>
An IEnumerable<T> of dynamic objects.
QueryAsync<TEntity>(IDataQueryAsync, Func<IDataReader, TEntity>, CancellationToken)
Executes the command against the connection and converts the results to TEntity
objects asynchronously.
public static Task<IEnumerable<TEntity>> QueryAsync<TEntity>(this IDataQueryAsync dataQuery, Func<IDataReader, TEntity> factory, CancellationToken cancellationToken = default)
Parameters
dataQuery
IDataQueryAsyncThe IDataQuery for this extension method.
factory
Func<IDataReader, TEntity>The delegate factory to convert the IDataReader to
TEntity
.cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task<IEnumerable<TEntity>>
An IEnumerable<T> of
TEntity
objects.
Type Parameters
TEntity
The type of the entity.
Exceptions
- ArgumentNullException
factory
is null
QuerySingle(IDataQuery)
Executes the query and returns the first row in the result as a dynamic object.
public static dynamic QuerySingle(this IDataQuery dataQuery)
Parameters
dataQuery
IDataQueryThe IDataQuery for this extension method.
Returns
- dynamic
A instance of a dynamic object if row exists; otherwise null.
QuerySingleAsync(IDataQueryAsync, CancellationToken)
Executes the query and returns the first row in the result as a dynamic object asynchronously.
public static Task<dynamic> QuerySingleAsync(this IDataQueryAsync dataQuery, CancellationToken cancellationToken = default)
Parameters
dataQuery
IDataQueryAsyncThe IDataQueryAsync for this extension method.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
QuerySingleAsync<TEntity>(IDataQueryAsync, Func<IDataReader, TEntity>, CancellationToken)
Executes the query and returns the first row in the result as a TEntity
object asynchronously.
public static Task<TEntity> QuerySingleAsync<TEntity>(this IDataQueryAsync dataQuery, Func<IDataReader, TEntity> factory, CancellationToken cancellationToken = default)
Parameters
dataQuery
IDataQueryAsyncThe IDataQuery for this extension method.
factory
Func<IDataReader, TEntity>The delegate factory to convert the IDataReader to
TEntity
.cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task<TEntity>
A instance of
TEntity
if row exists; otherwise null.
Type Parameters
TEntity
The type of the entity.
Exceptions
- ArgumentNullException
factory
is null
QueryValueAsync<TValue>(IDataQueryAsync, CancellationToken)
Executes the query and returns the first column of the first row in the result set returned by the query asynchronously. All other columns and rows are ignored.
public static Task<TValue> QueryValueAsync<TValue>(this IDataQueryAsync dataQuery, CancellationToken cancellationToken = default)
Parameters
dataQuery
IDataQueryAsyncThe IDataQuery for this extension method.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task<TValue>
The value of the first column of the first row in the result set.
Type Parameters
TValue
The type of the value.
QueryValue<TValue>(IDataQuery)
Executes the query and returns the first column of the first row in the result set returned by the query. All other columns and rows are ignored.
public static TValue QueryValue<TValue>(this IDataQuery dataQuery)
Parameters
dataQuery
IDataQueryThe IDataQuery for this extension method.
Returns
- TValue
The value of the first column of the first row in the result set.
Type Parameters
TValue
The type of the value.
QueryValuesAsync<TValue>(IDataQueryAsync, CancellationToken)
Executes the query and returns the first column values in the result set returned by the query. All other columns and rows are ignored.
public static Task<IEnumerable<TValue>> QueryValuesAsync<TValue>(this IDataQueryAsync dataQuery, CancellationToken cancellationToken = default)
Parameters
dataQuery
IDataQueryAsyncThe IDataQuery for this extension method.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task<IEnumerable<TValue>>
The value of the first column values in the result set.
Type Parameters
TValue
The type of the value.
QueryValues<TValue>(IDataQuery)
Executes the query and returns the first column values in the result set returned by the query. All other columns and rows are ignored.
public static IEnumerable<TValue> QueryValues<TValue>(this IDataQuery dataQuery)
Parameters
dataQuery
IDataQueryThe IDataQuery for this extension method.
Returns
- IEnumerable<TValue>
The value of the first column values in the result set.
Type Parameters
TValue
The type of the value.