CursorFind() public static method

public static CursorFind ( IntPtr handle, byte &keydata, byte &recdata, int flags ) : int
handle System.IntPtr
keydata byte
recdata byte
flags int
return int
Esempio n. 1
0
        /// <summary>
        /// Searches for a key and points the Cursor to this key
        /// </summary>
        /// <remarks>
        /// This method wraps the native ups_cursor_find function.
        /// <br />
        /// Searches for an item in the Database and points the Cursor to this
        /// item. If the item could not be found, the Cursor is not modified and the return value is null.
        /// <br />
        /// If the key has multiple duplicates, the Cursor is positioned
        /// on the first duplicate.
        /// </remarks>
        /// <param name="key">The key to search for</param>
        /// <param name="flags">The flags, can be zero</param>
        public byte[] TryFind(ref byte[] key, int flags)
        {
            int st;

            byte[] record = null;
            lock (db)
            {
                st = NativeMethods.CursorFind(handle, ref key, ref record, flags);
            }
            return(record);
        }
Esempio n. 2
0
        /// <summary>
        /// Searches a key and points the Cursor to this key
        /// </summary>
        /// <remarks>
        /// This method wraps the native ups_cursor_find function.
        /// <br />
        /// Searches for an item in the Database and points the Cursor to this
        /// item. If the item could not be found, the Cursor is not modified.
        /// <br />
        /// If the key has multiple duplicates, the Cursor is positioned
        /// on the first duplicate.
        /// </remarks>
        /// <param name="key">The key to search for</param>
        /// <param name="flags">The flags, can be zero</param>
        /// <exception cref="DatabaseException">
        ///   <list type="bullet">
        ///   <item><see cref="UpsConst.UPS_KEY_NOT_FOUND"/>
        ///     if the requested key was not found</item>
        ///   </list>
        /// </exception>
        public byte[] Find(ref byte[] key, int flags)
        {
            int st;

            byte[] record = null;
            lock (db) {
                st = NativeMethods.CursorFind(handle, ref key, ref record, flags);
            }
            if (st != 0)
            {
                throw new DatabaseException(st);
            }
            return(record);
        }