Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void PersistInsertion(IAggregateRoot aggregateRoot)
        {
            DatabaseType databaseType = RetrieveDatabaseTypeFrom(aggregateRoot);

            _objectContextFactory.Create().AddEntity <DatabaseType>(databaseType);
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="contextFactory"></param>
 public SingleUsageObjectContextAdapter(IObjectContextFactory contextFactory)
 {
     _contextFactory = contextFactory;
     ObjContext      = _contextFactory.Create();
 }