/// <summary> /// Protected wrapper for DB->put. Used by subclasses for access method /// specific operations. /// </summary> /// <param name="key">The key to store in the database</param> /// <param name="data">The data item to store in the database</param> /// <param name="txn">Transaction with which to protect the put</param> /// <param name="flags">Flags to pass to DB->put</param> protected void Put(DatabaseEntry key, DatabaseEntry data, Transaction txn, uint flags) { System.Type type = key.GetType(); if (type == typeof(MultipleDatabaseEntry)) flags |= DbConstants.DB_MULTIPLE; else if (type == typeof(MultipleKeyDatabaseEntry)) flags |= DbConstants.DB_MULTIPLE_KEY; db.put(Transaction.getDB_TXN(txn), key, data, flags); }
/// <summary> /// Remove key/data pairs from the database. If <paramref name="key"/> /// is DatabaseEntry, the key/data pair associated with /// <paramref name="key"/> is discarded from the database. In the /// presence of duplicate key values, all records associated with the /// designated key will be discarded. If <paramref name="key"/> is /// MultipleDatabaseEntry, delete multiple data items using keys from /// the buffer to which the key parameter refers. If /// <paramref name="key"/> is MultipleKeyDatabaseEntry, delete multiple /// data items using keys and data from the buffer to which the key /// parameter refers. /// </summary> /// <remarks> /// <para> /// When called on a secondary database, remove the key/data pairs from /// the primary database and all secondary indices. /// </para> /// <para> /// If <paramref name="txn"/> is null and the operation occurs in a /// transactional database, the operation will be implicitly transaction /// protected. /// </para> /// </remarks> /// <param name="key"> /// Discard the key/data pairs associated with <paramref name="key"/>. /// </param> /// <param name="txn"> /// If the operation is part of an application-specified transaction, /// <paramref name="txn"/> is a Transaction object returned from /// <see cref="DatabaseEnvironment.BeginTransaction"/>; if /// the operation is part of a Berkeley DB Concurrent Data Store group, /// <paramref name="txn"/> is a handle returned from /// <see cref="DatabaseEnvironment.BeginCDSGroup"/>; otherwise null. /// </param> /// <exception cref="NotFoundException"> /// A NotFoundException is thrown if <paramref name="key"/> is not in /// the database. /// </exception> /// <exception cref="KeyEmptyException"> /// A KeyEmptyException is thrown if the database is a /// <see cref="QueueDatabase"/> or <see cref="RecnoDatabase"/> /// database and <paramref name="key"/> exists, but was never explicitly /// created by the application or was later deleted. /// </exception> public void Delete(DatabaseEntry key, Transaction txn) { uint flags = 0; System.Type type = key.GetType(); if (type == typeof(MultipleDatabaseEntry)) flags |= DbConstants.DB_MULTIPLE; else if (type == typeof(MultipleKeyDatabaseEntry)) flags |= DbConstants.DB_MULTIPLE_KEY; db.del(Transaction.getDB_TXN(txn), key, flags); }