private void LoadAllocationTable() { using (ISession session = GetSession()) { try { using (ITransaction transaction = session.BeginTransaction()) { QueryParams <PersistentStorageAllocationTable> query = new QueryParams <PersistentStorageAllocationTable>( GetAllocationTableCriteria(), 1); IList <PersistentStorageAllocationTable> resultList = QueryHelper.Query <PersistentStorageAllocationTable>(session, query, LOG_QUERY); if (resultList.Count == 0) { this.mAllocationTable = new ItemTable(); } else { using (MemoryStream ms = new MemoryStream(resultList[0].ItemAllocationTableData)) { ms.Position = 0; this.mAllocationTable = SerializationHelper.Read <ItemTable>(ms, mTableFormatter, false); } } } } catch (Exception ex) { throw new PersistenceException("Unable to load allocation table.", ex); } } }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (disposing) { if (mAppIdMutex != null) { mAppIdMutex.Close(); mAppIdMutex = null; } //if (mAllocationTable != null) //{ // // remove all elements // try // { // using (ISession session = GetSession()) // { // using (ITransaction transaction = session.BeginTransaction()) // { // QueryParams<PersistentStorageAllocationTable> query = new QueryParams<PersistentStorageAllocationTable>( // GetAllocationTableCriteria(), 1); // IList<PersistentStorageAllocationTable> resultList = QueryHelper.Query<PersistentStorageAllocationTable>(session, query, LOG_QUERY); // if (resultList.Count > 0) // { // ORMUtils.DeleteEntity(resultList[0], session); // } // foreach (EntityId entityId in mAllocationTable.ItemIds) // { // RemoveObject(entityId, session); // } // transaction.Commit(); // } // } // } // catch (Exception) // { // } //} } mAllocationTable = null; mTableFormatter = null; base.Dispose(disposing); }