Upscaledb.Database.Erase C# (CSharp) Method

Erase() public method

Erases a Database Item
This method wraps the native ups_db_erase function.
This function erases a Database item. If the item with the specified key does not exist in the Database, error code UpsConst.UPS_KEY_NOT_FOUND is thrown.
Note that this method can not erase a single duplicate key. If the key has multiple duplicates, all duplicates of this key will be erased. Use Cursor.Erase to erase a specific duplicate key.
/// /// /// if the key was not found /// /// if you tried to insert a key in a read-only Database /// ///
public Erase ( Transaction txn, byte key ) : void
txn Transaction The optional Transaction
key byte The key of the item to delete
return void
        public void Erase(Transaction txn, byte[] key)
        {
            int st;
              lock (this) {
            st = NativeMethods.Erase(handle,
              txn != null ? txn.Handle : IntPtr.Zero, key, 0);
              }
              if (st != 0)
            throw new DatabaseException(st);
        }

Same methods

Database::Erase ( byte key ) : void

Usage Example

Ejemplo n.º 1
0
 private void EraseUnknownKey()
 {
     Upscaledb.Environment env = new Upscaledb.Environment();
     Database db = new Database();
     byte[] k = new byte[5];
     env.Create("ntest.db");
     db = env.CreateDatabase(1);
     try {
         db.Erase(k);
     }
     catch (DatabaseException e) {
         Assert.AreEqual(UpsConst.UPS_KEY_NOT_FOUND, e.ErrorCode);
     }
     db.Close();
     env.Close();
 }
All Usage Examples Of Upscaledb.Database::Erase