public virtual void SaveSomeData() { var dbContext = m_dbContextManager.OpenDbContext(); var newThing = new EfcThing { Value = 64.16 }; dbContext.Things.Add(newThing); }
protected virtual void SaveNewThing() { var dbContext = _dbContextManager.OpenDbContext(); var thing = new EfcThing { Value = 18.0 }; dbContext.Add(thing); dbContext.SaveChanges(); _thingId = thing.Id; }
protected virtual Guid SaveIt() { using (var dbContext = new ExampleDbContext(_dbContextOptions)) { var newThing = new EfcThing { Value = 45.0 }; dbContext.Add(newThing); dbContext.SaveChanges(); return(newThing.Id); } }
protected virtual void SaveNewThingWithFollowingError() { using (var dbContext = _dbContextManager.OpenDbContext()) { var thing = new EfcThing { Value = 37.0 }; dbContext.Add(thing); dbContext.SaveChanges(); _thingId = thing.Id; throw new InvalidOperationException("Artificial error after saving item"); } }
protected virtual void CalculatePi(Guid firstSessionId) { var dbContext = _getDbContext(); Assert.That(dbContext.DbContextId, Is.Not.EqualTo(firstSessionId), "because ISession is not thread safe and we want per-transaction semantics when Fork=true"); lock (_calculationsIds) { var newThing = new EfcThing { Value = 2 * CalculatePiInner(1) }; dbContext.Add(newThing); dbContext.SaveChanges(); _calculationsIds.Add(newThing.Id); } }
public virtual void MainThreadedEntry() { var dbContext = _getDbContext(); var newThing = new EfcThing { Value = 17.0 }; dbContext.Add(newThing); dbContext.SaveChanges(); _mainThingId = newThing.Id; _logger.Debug("put some cores ({0}) to work!", Environment.ProcessorCount); for (var i = 0; i < Environment.ProcessorCount; i++) { CalculatePi(dbContext.DbContextId); } }
public virtual void SaveNewThing() { logger.Debug("save new thing"); using (var dbContext = getDbContext()) { // at KTH this is an arbitrary number var thing = new EfcThing { Value = 17.0 }; dbContext.Add(thing); dbContext.SaveChanges(); id = thing.Id; logger.Debug("exiting using-block of session"); } }