コード例 #1
0
        public void DropCollection(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Collection name cant not be null or empty.");
            }

            if (!CollectionExists(name))
            {
                throw new ArgumentException("Specified collection not found in " + GetFileInfo() + " Collection = " + name);
            }

            ITransaction transaction = BeginTransactionInternal(null, TransactionBeginFlags.None);

            ValidateTransaction(transaction);
            LightningTransaction lmdbTransaction = (LightningTransaction)transaction.InnerObject;

            LightningDatabase dbInstance = _collectionTable[name].Collection;
            long dataSize = _collectionTable[name].Stats.DataSize;

            lmdbTransaction.DropDatabase(dbInstance);
            _collectionTable.Remove(name);

            StoreCollectionInfo(null, transaction);
            //StoreDocument(transaction, _metadataCollection, "collections", _collectionTable.Keys.ToArray());

            ((LMDBTransaction)transaction).ChangeSize(-8192);
            ((LMDBTransaction)transaction).ChangeSize(-dataSize);

            CommitInternal(transaction);
        }
コード例 #2
0
        public void DefaultDatabaseShouldBeDropped()
        {
            _txn = _env.BeginTransaction();
            var db = _txn.OpenDatabase(null, DatabaseOpenFlags.None);

            //arrange

            //act
            _txn.DropDatabase(db, true);

            //assert
            Assert.AreEqual(false, db.IsOpened);
        }
コード例 #3
0
        public void DefaultDatabaseShouldBeDropped()
        {
            _txn = _env.BeginTransaction();
            var db = _txn.OpenDatabase(null, DatabaseOpenFlags.None);
            //arrange

            //act
            _txn.DropDatabase(db, true);

            //assert
            Assert.AreEqual(false, db.IsOpened);
        }