Example #1
0
 public RemoteEsentStorage(RemoteEsentStorageState state)
 {
     instance          = state.Instance;
     database          = state.Database;
     tableColumnsCache = new TableColumnsCache();
     tableColumnsCache.InitColumDictionaries(instance, database);
 }
Example #2
0
 public DocumentStorageActions(
     JET_INSTANCE instance,
     string database,
     TableColumnsCache tableColumnsCache,
     OrderedPartCollection<AbstractDocumentCodec> documentCodecs,
     IUuidGenerator uuidGenerator,
     IDocumentCacher cacher,
     EsentTransactionContext transactionContext,
     TransactionalStorage transactionalStorage
     )
 {
     this.tableColumnsCache = tableColumnsCache;
     this.documentCodecs = documentCodecs;
     this.uuidGenerator = uuidGenerator;
     this.cacher = cacher;
     this.transactionalStorage = transactionalStorage;
     this.transactionContext = transactionContext;
     scheduledReductionsPerViewAndLevel = transactionalStorage.GetScheduledReductionsPerViewAndLevel();
     try
     {
         if (transactionContext == null)
         {
             session = new Session(instance);
             transaction = new Transaction(session);
             sessionAndTransactionDisposer = () =>
             {
                 if(transaction != null)
                     transaction.Dispose();
                 if(session != null)
                     session.Dispose();
             };
         }
         else
         {
             session = transactionContext.Session;
             transaction = transactionContext.Transaction;
             var disposable = transactionContext.EnterSessionContext();
             sessionAndTransactionDisposer = disposable.Dispose;
         }
         Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
     }
     catch (Exception ex)
     {
         string location;
         try
         {
             location = new StackTrace(true).ToString();
         }
         catch (Exception)
         {
             location = "cannot get stack trace";
         }
         logger.WarnException("Error when trying to open a new DocumentStorageActions from \r\n" + location, ex);
         try
         {
             Dispose();
         }
         catch (Exception e)
         {
             logger.WarnException("Error on dispose when the ctor threw an exception, resources may have leaked", e);
         }
         throw;
     }
 }