Interface IUnitOfWork
- Namespace
- Biwen.QuickApi.UnitOfWork
- Assembly
- Biwen.QuickApi.dll
Defines the interface(s) for unit of work.
public interface IUnitOfWork : IDisposable
- Inherited Members
- Extension Methods
Properties
LastSaveChangesResult
Last error after SaveChanges operation executed
SaveChangesResult LastSaveChangesResult { get; }
Property Value
Methods
BeginTransaction(bool)
Returns Transaction
IDbContextTransaction BeginTransaction(bool useIfExists = false)
Parameters
useIfExists
bool
Returns
BeginTransactionAsync(bool)
Returns Transaction
Task<IDbContextTransaction> BeginTransactionAsync(bool useIfExists = false)
Parameters
useIfExists
bool
Returns
ExecuteSqlCommand(string, params object[])
Executes the specified raw SQL command.
int ExecuteSqlCommand(string sql, params object[] parameters)
Parameters
Returns
- int
The number of state entities written to database.
ExecuteSqlCommandAsync(string, params object[])
Executes the specified raw SQL command.
Task<int> ExecuteSqlCommandAsync(string sql, params object[] parameters)
Parameters
Returns
FromSqlRaw<TEntity>(string, params object[])
Uses raw SQL queries to fetch the specified TEntity
data.
IQueryable<TEntity> FromSqlRaw<TEntity>(string sql, params object[] parameters) where TEntity : class
Parameters
Returns
- IQueryable<TEntity>
An IQueryable<T> that contains elements that satisfy the condition specified by raw SQL.
Type Parameters
TEntity
The type of the entity.
GetRepository<TEntity>(bool)
Gets the specified repository for the TEntity
.
IRepository<TEntity> GetRepository<TEntity>(bool hasCustomRepository = false) where TEntity : class
Parameters
hasCustomRepository
boolTrue
if providing custom repository
Returns
- IRepository<TEntity>
An instance of type inherited from IRepository<TEntity> interface.
Type Parameters
TEntity
The type of the entity.
SaveChanges()
Saves all changes made in this context to the database.
int SaveChanges()
Returns
- int
The number of state entries written to the database.
SaveChangesAsync()
Asynchronously saves all changes made in this unit of work to the database.
Task<int> SaveChangesAsync()
Returns
- Task<int>
A Task<TResult> that represents the asynchronous save operation. The task result contains the number of state entities written to database.
SetAutoDetectChanges(bool)
DbContext disable/enable auto detect changes
void SetAutoDetectChanges(bool value)
Parameters
value
bool
TrackGraph(object, Action<EntityEntryGraphNode>)
Uses Track Graph Api to attach disconnected entities
void TrackGraph(object rootEntity, Action<EntityEntryGraphNode> callback)
Parameters
rootEntity
objectRoot entity
callback
Action<EntityEntryGraphNode>Delegate to convert Object's State properties to Entities entry state.