本文整理汇总了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;
}
示例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);
}
示例4: ScheduleUnitOfWorkFactory
public ScheduleUnitOfWorkFactory(IDbContextFactory<ScheduleContext> contextFactory)
{
if (contextFactory == null)
throw new ArgumentNullException(nameof(contextFactory));
_contextFactory = contextFactory;
}
示例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);
}
示例6: OrderSaver
public OrderSaver(IDbContextFactory contextFactory,
IEntitySaver entitySaver,
IShipmentOrderItemsUpdater shipmentOrderItemsUpdater)
{
_contextFactory = contextFactory;
_entitySaver = entitySaver;
_shipmentOrderItemsUpdater = shipmentOrderItemsUpdater;
}
示例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);
}
示例8: MusicStoreUnitOfWork
public MusicStoreUnitOfWork(IDbContextFactory contextFactory)
{
if (contextFactory == null)
{
throw new ArgumentNullException("contextFactory");
}
_contextFactory = contextFactory;
}
示例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);
}
示例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");
}
示例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;
}
示例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;
}