/// <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); }
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); }
/// <summary> /// Initializes a new instance of the DesignTimeRepository class. /// </summary> /// <param name="getPrimaryKeyExpression">A lambda-expression that returns the entity primary key.</param> public DesignTimeRepository(DesignTimeUnitOfWork unitOfWork, Expression <Func <TEntity, TPrimaryKey> > getPrimaryKeyExpression) : base(unitOfWork) { this.getPrimaryKeyExpression = getPrimaryKeyExpression; this.entityTraits = ExpressionHelper.GetEntityTraits(this, getPrimaryKeyExpression); }
/// <summary> /// Initializes a new instance of the DesignTimeRepository class. /// </summary> /// <param name="getPrimaryKeyExpression">A lambda-expression that returns the entity primary key.</param> /// <param name="setPrimaryKeyAction">An action that provides a way to set an entity primary key in case the primary key is a nullable type, otherwise this parameter can be ommited.</param> public DesignTimeRepository(Expression <Func <TEntity, TPrimaryKey> > getPrimaryKeyExpression, Action <TEntity, TPrimaryKey> setPrimaryKeyAction = null) { this.getPrimaryKeyExpression = getPrimaryKeyExpression; this.entityTraits = ExpressionHelper.GetEntityTraits(this, getPrimaryKeyExpression, setPrimaryKeyAction); }