Interface IDataCommand
- Namespace
- FluentCommand
- Assembly
- FluentCommand.dll
An interface defining a data command.
public interface IDataCommand : IDataQuery, IDisposable, IDataQueryAsync, IAsyncDisposable
- Inherited Members
- Extension Methods
Properties
Command
Gets the underlying DbCommand for this DataCommand.
DbCommand Command { get; }
Property Value
Methods
CommandTimeout(int)
Sets the wait time (in seconds) before terminating the attempt to execute the command and generating an error.
IDataCommand CommandTimeout(int timeout)
Parameters
timeout
intThe time in seconds to wait for the command to execute.
Returns
- IDataCommand
A fluent interface to the data command.
Execute()
Executes the command against a connection.
int Execute()
Returns
- int
The number of rows affected.
ExecuteAsync(CancellationToken)
Executes the command against a connection asynchronously.
Task<int> ExecuteAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationToken
Returns
ExpireCache<TEntity>()
Expires cached items that have been cached using the current DataCommand.
IDataCommand ExpireCache<TEntity>()
Returns
- IDataCommand
A fluent interface to the data command.
Type Parameters
TEntity
The type of the entity.
Remarks
Cached keys are created using the current DataCommand state. When any Query opertion is executed with a cache policy, the results are cached. Use this method with the same parameters to expire the cached item.
LogState(object)
Use to pass a state to the IDataQueryLogger.
IDataCommand LogState(object state)
Parameters
state
objectThe state to pass to the logger.
Returns
- IDataCommand
A fluent interface to the data command.
Remarks
Use the state to help control what is logged.
Parameter(DbParameter)
Adds the parameter to the underlying command.
IDataCommand Parameter(DbParameter parameter)
Parameters
parameter
DbParameter
Returns
- IDataCommand
A fluent interface to the data command.
QueryMultiple(Action<IDataQuery>)
Executes the command against the connection and sends the resulting IDataQuery for reading multiple results sets.
void QueryMultiple(Action<IDataQuery> queryAction)
Parameters
queryAction
Action<IDataQuery>The query action delegate to pass the open IDataQuery for reading multiple results.
QueryMultipleAsync(Func<IDataQueryAsync, Task>, CancellationToken)
Executes the command against the connection and sends the resulting IDataQueryAsync for reading multiple results sets.
Task QueryMultipleAsync(Func<IDataQueryAsync, Task> queryAction, CancellationToken cancellationToken = default)
Parameters
queryAction
Func<IDataQueryAsync, Task>The query action delegate to pass the open IDataQueryAsync for reading multiple results.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
RegisterCallback<TParameter>(DbParameter, Action<TParameter>)
Register a return value callback
for the specified parameter
.
IDataCommand RegisterCallback<TParameter>(DbParameter parameter, Action<TParameter> callback)
Parameters
parameter
DbParameterThe IDbDataParameter to add.
callback
Action<TParameter>The callback used to get the out value.
Returns
- IDataCommand
A fluent interface to the data command.
Type Parameters
TParameter
The type of the parameter value.
Sql(string)
Set the data command with the specified SQL.
IDataCommand Sql(string sql)
Parameters
sql
stringThe SQL statement.
Returns
- IDataCommand
A fluent interface to a data command.
StoredProcedure(string)
Set the data command with the specified stored procedure name.
IDataCommand StoredProcedure(string storedProcedure)
Parameters
storedProcedure
stringName of the stored procedure.
Returns
- IDataCommand
A fluent interface to a data command.
UseCache(DateTimeOffset)
Uses cache to insert and retrieve cached results for the command with the specified absoluteExpiration
.
IDataCommand UseCache(DateTimeOffset absoluteExpiration)
Parameters
absoluteExpiration
DateTimeOffsetA value that indicates whether a cache entry should be evicted after a specified duration.
Returns
- IDataCommand
A fluent interface to the data command.
Exceptions
- InvalidOperationException
A command with Output or Return parameters can not be cached.
UseCache(TimeSpan)
Uses cache to insert and retrieve cached results for the command with the specified slidingExpiration
.
IDataCommand UseCache(TimeSpan slidingExpiration)
Parameters
slidingExpiration
TimeSpanA value that indicates whether a cache entry should be evicted if it has not been accessed in a given span of time.
Returns
- IDataCommand
A fluent interface to the data command.
Exceptions
- InvalidOperationException
A command with Output or Return parameters can not be cached.