April 2018
Intermediate to advanced
300 pages
7h 41m
English
We will implement the UnitOfWork pattern to save the context changes in a single call to the backend database. Updating the database on each object state change is not good practice and reduces the application performance. Consider an example of a form that contains a table where each row is editable. Committing a change in a database on each row update reduces application performance. The better way is to keep each row state in memory and update the database once the form is posted. With the Unit of Work pattern, we can define an interface that contains the following four methods:
public interface IUnitOfWork: IDisposable { void BeginTransaction(); void RollbackTransaction(); void CommitTransaction(); Task<bool> SaveChangesAsync(); ...