Advertisement
Guest User

Untitled

a guest
Dec 4th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public interface IBaseRepository<TEntity> where TEntity : BaseEntity
  2.  
  3. public class BaseRepository<TContext, TEntity> : IBaseRepository<TEntity> where TEntity : BaseEntity, new() where TContext : DbContext, new()
  4.  
  5.  
  6.  
  7. public interface IUnitOfWork : IDisposable
  8. {
  9. IBaseRepository<TEntity> GetRepository<TEntity>() where TEntity : BaseEntity;
  10. int SaveChanges();
  11.  
  12. }
  13.  
  14.  
  15.  
  16.  
  17. public class UnitOfWork : IUnitOfWork
  18. {
  19. public IBaseRepository<TEntity> GetRepository<TEntity>() where TEntity : BaseEntity
  20. {
  21.  
  22. return new BaseRepository<TEntity>(_context, Activator.CreateInstance(typeof(TEntity)));
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement