Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IBaseRepository<TEntity> where TEntity : BaseEntity
- public class BaseRepository<TContext, TEntity> : IBaseRepository<TEntity> where TEntity : BaseEntity, new() where TContext : DbContext, new()
- public interface IUnitOfWork : IDisposable
- {
- IBaseRepository<TEntity> GetRepository<TEntity>() where TEntity : BaseEntity;
- int SaveChanges();
- }
- public class UnitOfWork : IUnitOfWork
- {
- public IBaseRepository<TEntity> GetRepository<TEntity>() where TEntity : BaseEntity
- {
- return new BaseRepository<TEntity>(_context, Activator.CreateInstance(typeof(TEntity)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement