protected ObjectContext GetCurrentContext() { var storageExtension = OperationContextStorageExtension.Current; var objContext = storageExtension.Get <ObjectContext>(KeyName); if (objContext == null) { // No DbContext has been created for this operation yet. Create a new one... objContext = _contextFactory.Create(); // ... store it and make sure it will be Disposed when the operation is completed. storageExtension.Store(objContext, KeyName, () => objContext.Dispose()); } return(objContext); }
public void PersistInsertion(IAggregateRoot aggregateRoot) { DatabaseType databaseType = RetrieveDatabaseTypeFrom(aggregateRoot); _objectContextFactory.Create().AddEntity <DatabaseType>(databaseType); }
/// <summary> /// /// </summary> /// <param name="contextFactory"></param> public SingleUsageObjectContextAdapter(IObjectContextFactory contextFactory) { _contextFactory = contextFactory; ObjContext = _contextFactory.Create(); }