public IPocoRepository <T, TParent> ForPoco <T, TParent>(TParent parent, IDomainUnitOfWork uow) where T : class, new() where TParent : IEntity { var factory = Factories.GetOrAdd(typeof(T), t => ReflectionExtensions.BuildParentPocoRepositoryFunc <T, TParent>()) as Func <TParent, IMetrics, IStoreEvents, IStoreSnapshots, IDomainUnitOfWork, IPocoRepository <T, TParent> >; if (factory == null) { throw new InvalidOperationException("unknown entity repository"); } return(factory(parent, _metrics, _eventstore, _snapstore, uow)); }