Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Last active October 22, 2020 05:01
Show Gist options
  • Select an option

  • Save PradeepLoganathan/bc34427801a16f6e479459658d0a0604 to your computer and use it in GitHub Desktop.

Select an option

Save PradeepLoganathan/bc34427801a16f6e479459658d0a0604 to your computer and use it in GitHub Desktop.
UnitOfWork
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