/// <summary> /// Configures the options for all the repositories. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/> to add services.</param> /// <param name="optionAction">Configures the options for the repositories.</param> /// <returns>The same service collection so that multiple calls can be chained.</returns> public static IServiceCollection ConfigureRepositories( this IServiceCollection services, Action <GenericRepositoryOptions> optionAction = null) { var options = new GenericRepositoryOptions(); optionAction?.Invoke(options); services.TryAddSingleton(options); services.TryAddSingleton(services); return(services); }
public RepositoryFactory( GenericRepositoryOptions options, IServiceProvider serviceProvider, IServiceCollection serviceCollection) { _options = options; _serviceProvider = serviceProvider; _serviceCollection = serviceCollection; _dbContextFactory = GetDbContextFactory(); _dbContextFactoryType = _dbContextFactory?.GetType(); }