File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System . Threading ;
2+ using System . Threading . Tasks ;
3+
4+ namespace NetChris . Core . Patterns ;
5+
6+ /// <summary>
7+ /// Presents a unit of work interface to coordinate a unit-of-work pattern operation against a data store.
8+ /// </summary>
9+ /// <remarks>
10+ /// <para>
11+ /// There is no prescribed implementation of this of course. However the primary use of this will be to wrap the operations
12+ /// of an Entity Framework DbContext. And even though the DbContext's SaveChanges/Async operations constitute a unit
13+ /// of work in and of themselves, it's important to have a separate handle on the over-arching unit of work for:
14+ /// <list type="bullet">
15+ /// <item>Having an abstraction to use for testing in concert with repository abstractions.</item>
16+ /// <item>Handle the common exceptions that can occur when saving changes to the database, and then wrap them in well-known exceptions.</item>
17+ /// <item>Allow the ability to save/commit the unit of work without needing to reference the DbContext</item>
18+ /// </list>
19+ /// </para>
20+ /// </remarks>
21+ public interface IUnitOfWork
22+ {
23+ /// <summary>
24+ /// Commit the unit of work
25+ /// </summary>
26+ /// <param name="cancellationToken">The cancellation token</param>
27+ /// <returns>A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.</returns>
28+ Task < int > SaveChangesAsync ( CancellationToken cancellationToken = default ) ;
29+ }
You can’t perform that action at this time.
0 commit comments