Last active
October 22, 2020 05:01
-
-
Save PradeepLoganathan/bc34427801a16f6e479459658d0a0604 to your computer and use it in GitHub Desktop.
UnitOfWork
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UnitOfWork :IUnitOfWork | |
| { | |
| private readonly BookStoreDbContext _context; | |
| public IBooksRepository Books { get; } | |
| public ICatalogueRepository Catalogues { get; } | |
| public UnitOfWork(BookStoreDbContext bookStoreDbContext, | |
| IBooksRepository booksRepository, | |
| ICatalogueRepository catalogueRepository) | |
| { | |
| this._context = bookStoreDbContext; | |
| this.Books = booksRepository; | |
| this.Catalogues = catalogueRepository; | |
| } | |
| public int Complete() | |
| { | |
| return _context.SaveChanges(); | |
| } | |
| public void Dispose() | |
| { | |
| Dispose(true); | |
| GC.SuppressFinalize(this); | |
| } | |
| protected virtual void Dispose(bool disposing) | |
| { | |
| if (disposing) | |
| { | |
| _context.Dispose(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment