예제 #1
0
        protected InstantFeedbackCollectionViewModelBase(
            IUnitOfWorkFactory <TUnitOfWork> unitOfWorkFactory,
            Func <TUnitOfWork, IRepository <TEntity, TPrimaryKey> > getRepositoryFunc,
            Func <IRepositoryQuery <TEntity>, IQueryable <TProjection> > projection,
            Func <bool> canCreateNewEntity = null)
        {
            this.unitOfWorkFactory  = unitOfWorkFactory;
            this.canCreateNewEntity = canCreateNewEntity;
            this.getRepositoryFunc  = getRepositoryFunc;
            this.Projection         = projection;
            this.helperRepository   = CreateRepository();

            RepositoryExtensions.VerifyProjection(helperRepository, projection);

            this.source   = unitOfWorkFactory.CreateInstantFeedbackSource(getRepositoryFunc, Projection);
            this.Entities = InstantFeedbackSourceViewModel.Create(() => helperRepository.Count(), source);

            if (!this.IsInDesignMode())
            {
                OnInitializeInRuntime();
            }
        }