当前位置: 首页>>代码示例>>C#>>正文


C# IDbContextFactory类代码示例

本文整理汇总了C#中IDbContextFactory的典型用法代码示例。如果您正苦于以下问题:C# IDbContextFactory类的具体用法?C# IDbContextFactory怎么用?C# IDbContextFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IDbContextFactory类属于命名空间,在下文中一共展示了IDbContextFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DbContextReadOnlyScope

 public DbContextReadOnlyScope(IsolationLevel isolationLevel, IDbContextFactory dbContextFactory = null)
     : this(
         joiningOption: DbContextScopeOption.ForceCreateNew,
         isolationLevel: isolationLevel,
         dbContextFactory: dbContextFactory)
 {
 }
开发者ID:Perfectial,项目名称:Perfectial.EntityFramework.Enterprise.Sample,代码行数:7,代码来源:DbContextReadOnlyScope.cs

示例2: DbContextBuilder

 public DbContextBuilder(IDbContextFactory factory, IInterceptorsResolver interceptorsResolver, IRepository repository, IDbContextUtilities contextUtilities)
 {
     this.factory = factory;
     this.interceptorsResolver = interceptorsResolver;
     this.repository = repository;
     this.contextUtilities = contextUtilities;
 }
开发者ID:popcatalin81,项目名称:DataAccess,代码行数:7,代码来源:DbContextBuilder.cs

示例3: TestCustomerCreation

        public void TestCustomerCreation()
        {
            //Creating customer

            var Customer = new Customer() { CustomerName = "Customer 1", Telephome = "78-676-121212", Sites = new List<Site>() };
            Customer.Sites.Add(new Site() { Address = "Site 1", PostCode = "001", SiteNumber = "ST01" });
            Customer.Sites.Add(new Site() { Address = "Site 2", PostCode = "002", SiteNumber = "ST02" });

            iocCtxFactory = iocContainer.Resolve<IDbContextFactory>();
            var iocDBContext = iocCtxFactory.GetContext();

            //adding customer to database
            var sotredCustomer = iocDBContext.Set<Customer>().Add(Customer);
            iocDBContext.SaveChanges();
            var customerId = sotredCustomer.Id;

            //Test
            var nonIoCContext = new DbContextFactory().GetContext();

            var customerFrom_IOC_Context = iocCtxFactory.GetContext().Set<Customer>().Where(c => c.Id == customerId).SingleOrDefault();

            var customerNon_IOC_Context = nonIoCContext.Set<Customer>().Where(c => c.Id == customerId).SingleOrDefault();

            Assert.IsNull(customerNon_IOC_Context.Sites);

            //Expecting empty but having values if IOC lifestyle is singleton or PerWebRequest :(
            //transient is working as expected
            Assert.IsNull(customerFrom_IOC_Context.Sites);
        }
开发者ID:jithGit,项目名称:EFTDataAccess,代码行数:29,代码来源:IntegrationTest.cs

示例4: ScheduleUnitOfWorkFactory

        public ScheduleUnitOfWorkFactory(IDbContextFactory<ScheduleContext> contextFactory)
        {
            if (contextFactory == null)
                throw new ArgumentNullException(nameof(contextFactory));

            _contextFactory = contextFactory;
        }
开发者ID:tomlane,项目名称:OpenRailData,代码行数:7,代码来源:ScheduleUnitOfWorkFactory.cs

示例5: DbContextScope

        public DbContextScope(DbContextScopeOption joiningOption, bool readOnly, IsolationLevel? isolationLevel, IDbContextFactory dbContextFactory = null)
        {
            if (isolationLevel.HasValue && joiningOption == DbContextScopeOption.JoinExisting)
                throw new ArgumentException("Cannot join an ambient DbContextScope when an explicit database transaction is required. When requiring explicit database transactions to be used (i.e. when the 'isolationLevel' parameter is set), you must not also ask to join the ambient context (i.e. the 'joinAmbient' parameter must be set to false).");

            _disposed = false;
            _completed = false;
            _readOnly = readOnly;

            _parentScope = GetAmbientScope();
            if (_parentScope != null && joiningOption == DbContextScopeOption.JoinExisting)
            {
                if (_parentScope._readOnly && !this._readOnly)
                {
                    throw new InvalidOperationException("Cannot nest a read/write DbContextScope within a read-only DbContextScope.");
                }

                _nested = true;
                _dbContexts = _parentScope._dbContexts;
            }
            else
            {
                _nested = false;
                _dbContexts = new DbContextCollection(readOnly, isolationLevel, dbContextFactory);
            }

            SetAmbientScope(this);
        }
开发者ID:Misakai,项目名称:storage,代码行数:28,代码来源:DbContextScope.cs

示例6: OrderSaver

 public OrderSaver(IDbContextFactory contextFactory,
                   IEntitySaver entitySaver,
                   IShipmentOrderItemsUpdater shipmentOrderItemsUpdater)
 {
     _contextFactory = contextFactory;
     _entitySaver = entitySaver;
     _shipmentOrderItemsUpdater = shipmentOrderItemsUpdater;
 }
开发者ID:bjorse,项目名称:tdd-demo,代码行数:8,代码来源:OrderSaver.cs

示例7: UnitOfWorkEf

        /// <summary>
        ///     Инициализирует новый экземпляр класса <see cref="UnitOfWorkEf" />
        /// </summary>
        /// <param name="contextFactory">Фабрика контекста доступа к БД</param>
        /// <param name="isolationLevel">Уровень изоляции данных</param>
        public UnitOfWorkEf(
            IDbContextFactory contextFactory,
            IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
        {
            this._context = contextFactory.CreateDbContext<EntitiesContext>();

            // Если БД не была создана вызовет ошибку
            this._transaction = this._context.Database.BeginTransaction(isolationLevel);
        }
开发者ID:DofD,项目名称:UnitOfWork,代码行数:14,代码来源:UnitOfWorkEf.cs

示例8: MusicStoreUnitOfWork

        public MusicStoreUnitOfWork(IDbContextFactory contextFactory)
        {
            if (contextFactory == null)
            {
                throw new ArgumentNullException("contextFactory");
            }

            _contextFactory = contextFactory;
        }
开发者ID:Bogatinov,项目名称:WebApi2-ONION,代码行数:9,代码来源:UnitOfWork.cs

示例9: DefaultRepositoryConfigurationSettings

        public DefaultRepositoryConfigurationSettings(IDbContextFactory dbContextFactory)
        {
            DbContextFactory = dbContextFactory ?? Create.New<IDbContextFactory>();

            ShouldValidate = true;
            ShouldWrapInTransaction = true;
            ShouldIncludeDependencies = false;
            ShouldTrackEntities = false;
        }
开发者ID:TylerGarlick,项目名称:RedRocket.Persistence.EF,代码行数:9,代码来源:DefaultRepositoryConfigurationSettings.cs

示例10: EntityFrameworkUnitOfWorkFactory

        public EntityFrameworkUnitOfWorkFactory(IConfiguration configuration, IDbContextFactory contextFactory, IDbConfiguration dbConfiguration)
        {
            if (configuration == null) throw new ArgumentNullException("configuration");
            if (contextFactory == null) throw new ArgumentNullException("contextFactory");
            if (dbConfiguration == null) throw new ArgumentNullException("dbConfiguration");

            _configuration = configuration;
            _contextFactory = contextFactory;
            _dbConfiguration = dbConfiguration;
            _contextType = null;
        }
开发者ID:vvmoppescapita,项目名称:AccidentalFish.ApplicationSupport,代码行数:11,代码来源:EntityFrameworkUnitOfWorkFactory.cs

示例11: SetupGameStuff

 public SetupGameStuff(IDbContextLocator locator, IDbContextFactory factory,
     INetworkContentSyncer networkContentSyncer, /* ICacheManager cacheMan, */
     IGameLocker gameLocker, IStateHandler stateHandler, IAssemblyService ass) {
     _locator = locator;
     _factory = factory;
     _networkContentSyncer = networkContentSyncer;
     //_cacheMan = cacheMan;
     _gameLocker = gameLocker;
     _stateHandler = stateHandler;
     _timer = new TimerWithElapsedCancellationAsync(TimeSpan.FromMinutes(30), onElapsedNonBool: OnElapsed);
     _gameFactory = new GameFactory(ass);
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:12,代码来源:SetupGameStuff.cs

示例12: EventLogger

        public EventLogger(IDbContextFactory dbContextFactory)
        {
            var dbContext = dbContextFactory.GetContext();
            _dbPackageEventSet = dbContext.Set<PackageEvent>();
            _dbSchedulerEventSet = dbContext.Set<SchedulerEvent>();
            _dbServerEventSet = dbContext.Set<ServerEvent>();
            _dbSystemEventSet = dbContext.Set<SystemEvent>();
            _dbServerDeploymentEventSet = dbContext.Set<ServerDeploymentEvent>();
            _dbNotificationSet = dbContext.Set<Notification>();
            _dbNotificationTypeSet = dbContext.Set<NotificationType>();

            intNotificationTypeID = FindNotificationType("MindAlign");
        }
开发者ID:sap-sh,项目名称:t,代码行数:13,代码来源:EventLogger.cs

示例13: EntityFrameworkUnitOfWorkFactory

        public EntityFrameworkUnitOfWorkFactory(
            IConfiguration configuration,
            IDbContextFactory contextFactory,
            IDbConfiguration dbConfiguration,
            IEntityFrameworkRepositoryLogger logger) : this(logger)
        {
            if (configuration == null) throw new ArgumentNullException(nameof(configuration));
            if (contextFactory == null) throw new ArgumentNullException(nameof(contextFactory));
            if (dbConfiguration == null) throw new ArgumentNullException(nameof(dbConfiguration));

            _configuration = configuration;
            _contextFactory = contextFactory;
            _dbConfiguration = dbConfiguration;
            _contextType = null;
        }
开发者ID:JamesRandall,项目名称:AccidentalFish.ApplicationSupport,代码行数:15,代码来源:EntityFrameworkUnitOfWorkFactory.cs

示例14: GetCurrentDbContext

 private static DbContextContainer GetCurrentDbContext(IDbContextFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException("factory");
     }
     if (factory.DbContextContainer == null)
     {
         throw new Exception("没有配置CurrentDbContext");
     }
     DbContextContainer currentDbContext = factory.DbContextContainer as DbContextContainer;
     if (currentDbContext == null)
     {
         throw new Exception("Current DbContext没有继承CurrentDbContext");
     }
     return currentDbContext;
 }
开发者ID:panshuiqing,项目名称:winform-ui,代码行数:17,代码来源:DbContextContainer.cs

示例15: UpdateService

      /// <exception cref="ArgumentNullException">
      /// <paramref name="serverImagesPath"/> or
      /// <paramref name="archiveDirectoryPath"/> or
      /// <paramref name="contextFactory"/> or
      /// <paramref name="dateTimeProxy"/> or
      /// <paramref name="activatorProxy"/> is <see langword="null" />.</exception>
      internal UpdateService(string serverImagesPath, string archiveDirectoryPath, IDbContextFactory<UpdateDbContext> contextFactory,
         IDateTimeProxy dateTimeProxy, IActivatorProxy activatorProxy)
      {
         if (serverImagesPath == null)
            throw new ArgumentNullException("serverImagesPath");

         if (archiveDirectoryPath == null)
            throw new ArgumentNullException("archiveDirectoryPath");

         if (contextFactory == null)
            throw new ArgumentNullException("contextFactory");

         if (dateTimeProxy == null)
            throw new ArgumentNullException("dateTimeProxy");

         if (activatorProxy == null)
            throw new ArgumentNullException("activatorProxy");

         _serverImagesPath = serverImagesPath;
         _archiveDirectoryPath = archiveDirectoryPath;
         _contextFactory = contextFactory;
         _dateTimeProxy = dateTimeProxy;
         _activatorProxy = activatorProxy;
      }
开发者ID:ssh-git,项目名称:training-manager,代码行数:30,代码来源:UpdateService.cs


注:本文中的IDbContextFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。