private static IUnityContainer ConfigureStorage(this IUnityContainer container, ISqlStoreSettingsAspect storageSettings, Func <LifetimeManager> entryPointSpecificLifetimeManagerFactory) { // разрешаем update на таблицу состоящую только из Primary Keys LinqToDB.Common.Configuration.Linq.IgnoreEmptyUpdate = true; var transactionOptions = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.Zero }; var schemaMapping = new Dictionary <string, MappingSchema> { { Scope.Erm, Schema.Erm }, { Scope.Facts, Schema.Facts }, { Scope.CustomerIntelligence, Schema.CustomerIntelligence }, { Scope.Transport, TransportSchema.Transport }, }; return(container .RegisterType <IEqualityComparerFactory, EqualityComparerFactory>(Lifetime.Singleton) .RegisterType <IPendingChangesHandlingStrategy, NullPendingChangesHandlingStrategy>(Lifetime.Singleton) .RegisterType <IStorageMappingDescriptorProvider, StorageMappingDescriptorProvider>(Lifetime.Singleton) .RegisterType <IEntityContainerNameResolver, DefaultEntityContainerNameResolver>(Lifetime.Singleton) .RegisterType <IManagedConnectionStateScopeFactory, ManagedConnectionStateScopeFactory>(Lifetime.Singleton) .RegisterType <IDomainContextScope, DomainContextScope>(entryPointSpecificLifetimeManagerFactory()) .RegisterType <ScopedDomainContextsStore>(entryPointSpecificLifetimeManagerFactory()) .RegisterType <IReadableDomainContext, CachingReadableDomainContext>(entryPointSpecificLifetimeManagerFactory()) .RegisterType <IProcessingContext, ProcessingContext>(entryPointSpecificLifetimeManagerFactory()) .RegisterInstance <ILinqToDbModelFactory>( new LinqToDbModelFactory(schemaMapping, transactionOptions, storageSettings.SqlCommandTimeout), Lifetime.Singleton) .RegisterInstance <IObjectPropertyProvider>( new LinqToDbPropertyProvider(schemaMapping.Values.ToArray()), Lifetime.Singleton) .RegisterType <IWritingStrategyFactory, WritingStrategyFactory>() .RegisterType <IReadableDomainContextFactory, LinqToDBDomainContextFactory>(entryPointSpecificLifetimeManagerFactory()) .RegisterType <IModifiableDomainContextFactory, LinqToDBDomainContextFactory>(entryPointSpecificLifetimeManagerFactory()) .RegisterType <IQuery, Query>(entryPointSpecificLifetimeManagerFactory()) .RegisterType(typeof(IRepository <>), typeof(LinqToDBRepository <>), entryPointSpecificLifetimeManagerFactory()) .RegisterType <IReadableDomainContextProvider, ReadableDomainContextProvider>(entryPointSpecificLifetimeManagerFactory()) .RegisterType <IModifiableDomainContextProvider, ModifiableDomainContextProvider>(entryPointSpecificLifetimeManagerFactory()) .RegisterType(typeof(IBulkRepository <>), typeof(BulkRepository <>), entryPointSpecificLifetimeManagerFactory()) .ConfigureReadWriteModels()); }
private static IUnityContainer ConfigureStorage(this IUnityContainer container, ISqlStoreSettingsAspect storageSettings, Func<LifetimeManager> entryPointSpecificLifetimeManagerFactory) { // разрешаем update на таблицу состоящую только из Primary Keys LinqToDB.Common.Configuration.Linq.IgnoreEmptyUpdate = true; var transactionOptions = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.Zero }; var schemaMapping = new Dictionary<string, MappingSchema> { { Scope.Erm, Schema.Erm }, { Scope.Facts, Schema.Facts }, { Scope.CustomerIntelligence, Schema.CustomerIntelligence }, { Scope.Transport, TransportSchema.Transport }, }; return container .RegisterType<IEqualityComparerFactory, EqualityComparerFactory>(Lifetime.Singleton) .RegisterType<IPendingChangesHandlingStrategy, NullPendingChangesHandlingStrategy>(Lifetime.Singleton) .RegisterType<IStorageMappingDescriptorProvider, StorageMappingDescriptorProvider>(Lifetime.Singleton) .RegisterType<IEntityContainerNameResolver, DefaultEntityContainerNameResolver>(Lifetime.Singleton) .RegisterType<IManagedConnectionStateScopeFactory, ManagedConnectionStateScopeFactory>(Lifetime.Singleton) .RegisterType<IDomainContextScope, DomainContextScope>(entryPointSpecificLifetimeManagerFactory()) .RegisterType<ScopedDomainContextsStore>(entryPointSpecificLifetimeManagerFactory()) .RegisterType<IReadableDomainContext, CachingReadableDomainContext>(entryPointSpecificLifetimeManagerFactory()) .RegisterType<IProcessingContext, ProcessingContext>(entryPointSpecificLifetimeManagerFactory()) .RegisterInstance<ILinqToDbModelFactory>( new LinqToDbModelFactory(schemaMapping, transactionOptions, storageSettings.SqlCommandTimeout), Lifetime.Singleton) .RegisterInstance<IObjectPropertyProvider>( new LinqToDbPropertyProvider(schemaMapping.Values.ToArray()), Lifetime.Singleton) .RegisterType<IWritingStrategyFactory, WritingStrategyFactory>() .RegisterType<IReadableDomainContextFactory, LinqToDBDomainContextFactory>(entryPointSpecificLifetimeManagerFactory()) .RegisterType<IModifiableDomainContextFactory, LinqToDBDomainContextFactory>(entryPointSpecificLifetimeManagerFactory()) .RegisterType<IQuery, Query>(entryPointSpecificLifetimeManagerFactory()) .RegisterType(typeof(IRepository<>), typeof(LinqToDBRepository<>), entryPointSpecificLifetimeManagerFactory()) .RegisterType<IReadableDomainContextProvider, ReadableDomainContextProvider>(entryPointSpecificLifetimeManagerFactory()) .RegisterType<IModifiableDomainContextProvider, ModifiableDomainContextProvider>(entryPointSpecificLifetimeManagerFactory()) .RegisterType(typeof(IBulkRepository<>), typeof(BulkRepository<>), entryPointSpecificLifetimeManagerFactory()) .ConfigureReadWriteModels(); }