/// <summary> /// Initializes a new instance of DbRepository class. /// </summary> /// <param name="unitOfWork">Owner unit of work that provides context for repository entities.</param> /// <param name="dbSetAccessor">Function that returns DbSet entities from Entity Framework DbContext.</param> /// <param name="getPrimaryKeyExpression">Lambda-expression that returns entity primary key.</param> public DbRepository(DbUnitOfWork <TDbContext> unitOfWork, Func <TDbContext, DbSet <TEntity> > dbSetAccessor, Expression <Func <TEntity, TPrimaryKey> > getPrimaryKeyExpression) : base(unitOfWork, dbSetAccessor) { this.getPrimaryKeyExpression = getPrimaryKeyExpression; this.entityTraits = ExpressionHelper.GetEntityTraits(this, getPrimaryKeyExpression); }
/// <summary> /// Initializes a new instance of DbReadOnlyRepository class. /// </summary> /// <param name="unitOfWork">Owner unit of work that provides context for repository entities.</param> /// <param name="dbSetAccessor">Function that returns DbSet entities from Entity Framework DbContext.</param> public DbReadOnlyRepository(DbUnitOfWork <TDbContext> unitOfWork, Func <TDbContext, DbSet <TEntity> > dbSetAccessor) : base(() => dbSetAccessor(unitOfWork.Context)) { this.dbSetAccessor = dbSetAccessor; this.unitOfWork = unitOfWork; }