public DbReadOnlyRepository(DbUnitOfWork <TDbContext> unitOfWork, Func <TDbContext, DataServiceQuery <TEntity> > dbSetAccessor, bool useExtendedDataQuery) : base(() => dbSetAccessor(unitOfWork.Context), null, useExtendedDataQuery) { this.dbSetAccessor = dbSetAccessor; this.unitOfWork = unitOfWork; this.localCollection = new Lazy <DataServiceCollection <TEntity> >(() => new DataServiceCollection <TEntity>(DbSet.Where(x => false))); }
public DbRepository(DbUnitOfWork <TDbContext> unitOfWork, Expression <Func <TDbContext, DataServiceQuery <TEntity> > > dbSetAccessorExpression, Expression <Func <TEntity, TPrimaryKey> > getPrimaryKeyExpression, bool useExtendedDataQuery) : base(unitOfWork, dbSetAccessorExpression.Compile(), useExtendedDataQuery) { Expression body = dbSetAccessorExpression.Body; while (body is MethodCallExpression) { body = ((MethodCallExpression)body).Object; } this.dbSetName = ((MemberExpression)body).Member.Name; this.getPrimaryKeyExpression = getPrimaryKeyExpression; this.entityTraits = ExpressionHelper.GetEntityTraits(this, getPrimaryKeyExpression); }