public ProxyReadOnlyFreeRepository(IServiceProvider serviceProvider) { var factory = serviceProvider.GetService <IFreeRepositoryFactory <TEntity, TKey> >() ?? throw new NullReferenceException($"Cannot get a {nameof(IFreeRepositoryFactory<TEntity, TKey>)} instance."); _inner = factory.CreateReadOnlyFreeRepository(); }