UnitOfWork Class
Assembly: PTS.DomainFramework.Infrastructure.dll
Syntax
public class UnitOfWork : ServiceProviderAccessor, IUnitOfWork, IServiceProviderAccessor, IHasDbContext
Inheritance
System.Object
UnitOfWork
Constructors
UnitOfWork(IServiceProvider, DbContext, IRepositoryFactory)
Declaration
public UnitOfWork(IServiceProvider serviceProvider, DbContext dbContext, IRepositoryFactory factory)
Parameters
Type |
Name |
Description |
System.IServiceProvider |
serviceProvider |
|
Microsoft.EntityFrameworkCore.DbContext |
dbContext |
|
IRepositoryFactory |
factory |
|
Properties
DbContext
Declaration
public DbContext DbContext { get; }
Property Value
Type |
Description |
Microsoft.EntityFrameworkCore.DbContext |
|
Factory
Declaration
protected IRepositoryFactory Factory { get; }
Property Value
Methods
Repository(Type)
Declaration
public IRepository Repository(Type entityType)
Parameters
Type |
Name |
Description |
System.Type |
entityType |
|
Returns
Repository<TEntity>()
Declaration
public IRepository<TEntity> Repository<TEntity>()
where TEntity : class
Returns
Type Parameters
Explicit Interface Implementations
IUnitOfWork.SaveChanges()
Saves all changes made in the unit if work to storage.
Declaration
int IUnitOfWork.SaveChanges()
Returns
Type |
Description |
System.Int32 |
The number of state entries written to the storage.
|
IUnitOfWork.SaveChanges(Object)
Declaration
int IUnitOfWork.SaveChanges(object sender)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
Returns
Type |
Description |
System.Int32 |
|
IUnitOfWork.SaveChangesAsync(Object, CancellationToken)
Declaration
Task<int> IUnitOfWork.SaveChangesAsync(object sender, CancellationToken cancellationToken)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Int32> |
|
IUnitOfWork.SaveChangesAsync(CancellationToken)
Asynchronously saves all changes made in the unit if work to the storage.
Declaration
Task<int> IUnitOfWork.SaveChangesAsync(CancellationToken cancellationToken)
Parameters
Type |
Name |
Description |
System.Threading.CancellationToken |
cancellationToken |
A cancellation token to observe while waiting for the task to complete.
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Int32> |
A task that represents the asynchronous save operation. The task result contains the number of state entries written to the storage.
|
Implements
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Extension Methods