Interface IDataSession
- Namespace
- FluentCommand
- Assembly
- FluentCommand.dll
An interface for data sessions.
public interface IDataSession : IDisposable, IAsyncDisposable
- Inherited Members
- Extension Methods
Properties
Cache
Gets the underlying IDataCache for the session.
IDataCache Cache { get; }
Property Value
Connection
Gets the underlying DbConnection for the session.
DbConnection Connection { get; }
Property Value
QueryGenerator
Gets the query generator provider.
IQueryGenerator QueryGenerator { get; }
Property Value
- IQueryGenerator
The query generator provider.
QueryLogger
Gets the data command query logger.
IDataQueryLogger QueryLogger { get; }
Property Value
- IDataQueryLogger
The data command query logger.
Transaction
Gets the underlying DbTransaction for the session.
DbTransaction Transaction { get; }
Property Value
Methods
BeginTransaction(IsolationLevel)
Starts a database transaction with the specified isolation level.
DbTransaction BeginTransaction(IsolationLevel isolationLevel)
Parameters
isolationLevel
IsolationLevelSpecifies the isolation level for the transaction.
Returns
- DbTransaction
A DbTransaction representing the new transaction.
BeginTransactionAsync(IsolationLevel, CancellationToken)
Starts a database transaction with the specified isolation level.
Task<DbTransaction> BeginTransactionAsync(IsolationLevel isolationLevel = IsolationLevel.Unspecified, CancellationToken cancellationToken = default)
Parameters
isolationLevel
IsolationLevelSpecifies the isolation level for the transaction.
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task<DbTransaction>
A DbTransaction representing the new transaction.
EnsureConnection()
Ensures the connection is open.
void EnsureConnection()
EnsureConnectionAsync(CancellationToken)
Ensures the connection is open asynchronous.
Task EnsureConnectionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation instruction.
Returns
- Task
A task representing the asynchronous operation.
Exceptions
- InvalidOperationException
Failed to open connection
ReleaseConnection()
Releases the connection.
void ReleaseConnection()
ReleaseConnectionAsync()
Releases the connection.
Task ReleaseConnectionAsync()
Returns
Sql(string)
Starts a 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)
Starts a data command with the specified stored procedure name.
IDataCommand StoredProcedure(string storedProcedureName)
Parameters
storedProcedureName
stringName of the stored procedure.
Returns
- IDataCommand
A fluent interface to a data command.