예제 #1
0
 /// <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>
 /// <param name="setPrimaryKeyAction">
 ///     Action that provides a way to set entity primary key in case primary key is a
 ///     nullable type, otherwise this parameter can be ommited.
 /// </param>
 public DbRepository(DbUnitOfWork <TDbContext> unitOfWork, Func <TDbContext, DbSet <TEntity> > dbSetAccessor,
                     Expression <Func <TEntity, TPrimaryKey> > getPrimaryKeyExpression,
                     Action <TEntity, TPrimaryKey> setPrimaryKeyAction = null)
     : base(unitOfWork, dbSetAccessor)
 {
     this.getPrimaryKeyExpression = getPrimaryKeyExpression;
     entityTraits = ExpressionHelper.GetEntityTraits(this, getPrimaryKeyExpression, setPrimaryKeyAction);
 }
예제 #2
0
 /// <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)
 {
     this.dbSetAccessor = dbSetAccessor;
     this.unitOfWork    = unitOfWork;
 }