/// <summary> /// Temporarily limits the set of index entries that the cursor can walk using /// JetMove to those starting from the current index entry and ending at the index /// entry that matches the search criteria specified by the search key in that cursor /// and the specified bound criteria. A search key must have been previously constructed /// using JetMakeKey. Returns true if the index range is non-empty, false otherwise. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The cursor to position.</param> /// <param name="grbit">Seek option.</param> /// <returns>True if the seek was successful.</returns> public static bool TrySetIndexRange(JET_SESID sesid, JET_TABLEID tableid, SetIndexRangeGrbit grbit) { var err = (JET_err)Impl.JetSetIndexRange(sesid, tableid, grbit); if (JET_err.NoCurrentRecord == err) { return(false); } Api.Check((int)err); Debug.Assert(err >= JET_err.Success, "Exception should have been thrown in case of error"); return(true); }
/// <summary> /// Create an index range on the cursor, controlling which records will be enumerated. /// After this call the cursor will be positioned on range.Max and can be enumerated /// backwards to range.Min with TryMovePrevious. /// </summary> /// <param name="range">The range to set.</param> /// <returns>False if the range is empty.</returns> public bool SetReverseIndexRange(KeyRange <TKey> range) { if (range.IsEmpty) { return(false); } if (null != range.Max) { // The possibilities we have here are: // 1. Key = 'k', exclusive: seek for < 'k' // 2. Key = 'k', inclusive: seek for <= 'k' // 3. Key = 'k', prefix: make a prefix key and seek LE if (range.Max.IsPrefix) { this.MakePrefixKey(range.Max.Value); } else { this.MakeKey(range.Max.Value); } SeekGrbit grbit = range.Max.IsInclusive ? SeekGrbit.SeekLE : SeekGrbit.SeekLT; if (!Api.TrySeek(this.sesid, this.dataTable, grbit)) { return(false); } } else { Api.MoveAfterLast(this.sesid, this.dataTable); if (!Api.TryMovePrevious(this.sesid, this.dataTable)) { return(false); } } if (null != range.Min) { this.MakeKey(range.Min.Value); SetIndexRangeGrbit grbit = range.Min.IsInclusive ? SetIndexRangeGrbit.RangeInclusive : SetIndexRangeGrbit.None; return(Api.TrySetIndexRange(this.sesid, this.dataTable, grbit)); } return(true); }
/// <summary> /// Create an index range on the cursor, controlling which records will be enumerated. /// </summary> /// <param name="range">The range to set.</param> /// <returns>False if the range is empty.</returns> public bool SetIndexRange(KeyRange <TKey> range) { if (range.IsEmpty) { return(false); } if (null != range.Min) { this.MakeKey(range.Min.Value); SeekGrbit grbit = range.Min.IsInclusive ? SeekGrbit.SeekGE : SeekGrbit.SeekGT; if (!Api.TrySeek(this.sesid, this.dataTable, grbit)) { return(false); } } else { Api.MoveBeforeFirst(this.sesid, this.dataTable); if (!Api.TryMoveNext(this.sesid, this.dataTable)) { return(false); } } if (null != range.Max) { if (range.Max.IsPrefix) { this.MakePrefixKey(range.Max.Value); } else { this.MakeKey(range.Max.Value); } SetIndexRangeGrbit grbit = SetIndexRangeGrbit.RangeUpperLimit | (range.Max.IsInclusive ? SetIndexRangeGrbit.RangeInclusive : SetIndexRangeGrbit.None); return(Api.TrySetIndexRange(this.sesid, this.dataTable, grbit)); } return(true); }
/// <summary> /// Temporarily limits the set of index entries that the cursor can walk using /// JetMove to those starting from the current index entry and ending at the index /// entry that matches the search criteria specified by the search key in that cursor /// and the specified bound criteria. A search key must have been previously constructed /// using JetMakeKey. Returns true if the index range is non-empty, false otherwise. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The cursor to position.</param> /// <param name="grbit">Seek option.</param> /// <returns>True if the seek was successful.</returns> public static bool TrySetIndexRange(JET_SESID sesid, JET_TABLEID tableid, SetIndexRangeGrbit grbit) { var err = (JET_err)Impl.JetSetIndexRange(sesid, tableid, grbit); if (JET_err.NoCurrentRecord == err) { return false; } Api.Check((int)err); Debug.Assert(err >= JET_err.Success, "Exception should have been thrown in case of error"); return true; }
/// <summary> /// Temporarily limits the set of index entries that the cursor can walk using /// <see cref="JetMove(JET_SESID,JET_TABLEID,int,MoveGrbit)"/> to those starting /// from the current index entry and ending at the index entry that matches the /// search criteria specified by the search key in that cursor and the specified /// bound criteria. A search key must have been previously constructed using /// <see cref="JetMakeKey(JET_SESID,JET_TABLEID,byte[],int,MakeKeyGrbit)"/>. /// Also see <seealso cref="TrySetIndexRange"/>. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The cursor to set the index range on.</param> /// <param name="grbit">Index range options.</param> public static void JetSetIndexRange(JET_SESID sesid, JET_TABLEID tableid, SetIndexRangeGrbit grbit) { Api.Check(Impl.JetSetIndexRange(sesid, tableid, grbit)); }
/// <summary> /// Restricts the records that are visible to the cursor to a range of /// the current index delineated by the specified keys. /// </summary> /// <param name="keyStart">The partial or full key used to set the start of the records to find on the current index</param> /// <param name="criteriaStart">Indicates if the starting key is inclusive or exclusive</param> /// <param name="keyEnd">The partial or full key used to set the end of the records to find on the current index</param> /// <param name="criteriaEnd">Indicates if the ending key is inclusive or exclusive</param> /// <remarks> /// The restriction will remain in effect until explicitly reset or /// until implicitly reset by other methods as noted. /// <para> /// Any previously defined restriction will be cleared. /// </para> /// <para> /// The cursor will be positioned before the first record in the new /// restriction. /// </para> /// </remarks> public void FindRecordsBetween(Key keyStart, BoundCriteria criteriaStart, Key keyEnd, BoundCriteria criteriaEnd) { lock (this.isamSession) { this.CheckDisposed(); this.OnNavigation(); // clear our index range this.FindAllRecords(); // setup the effective index range to be bounded by the specified keys this.keyStart = this.MakeKey(keyStart, false); this.grbitSeekStart = criteriaStart == BoundCriteria.Inclusive ? SeekGrbit.SeekGE : SeekGrbit.SeekGT; this.grbitRangeStart = criteriaStart == BoundCriteria.Inclusive ? SetIndexRangeGrbit.RangeInclusive : SetIndexRangeGrbit.None; this.keyEnd = this.MakeKey(keyEnd, true); this.grbitSeekEnd = criteriaEnd == BoundCriteria.Inclusive ? SeekGrbit.SeekLE : SeekGrbit.SeekLT; this.grbitRangeEnd = (criteriaEnd == BoundCriteria.Inclusive ? SetIndexRangeGrbit.RangeInclusive : SetIndexRangeGrbit.None) | SetIndexRangeGrbit.RangeUpperLimit; // move before first on the new index range this.MoveBeforeFirst(); } }
/// <summary> /// Temporarily limits the set of index entries that the cursor can walk using /// JetMove to those starting from the current index entry and ending at the index /// entry that matches the search criteria specified by the search key in that cursor /// and the specified bound criteria. A search key must have been previously constructed /// using JetMakeKey. Returns true if the index range is non-empty, false otherwise. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The cursor to position.</param> /// <param name="grbit">Seek option.</param> /// <returns>True if the seek was successful.</returns> public static bool TrySetIndexRange(JET_SESID sesid, JET_TABLEID tableid, SetIndexRangeGrbit grbit) { var err = (JET_err)Impl.JetSetIndexRange(sesid, tableid, grbit); if (err >= JET_err.Success) { return true; } else if (JET_err.NoCurrentRecord == err) { return false; } Api.Check((int)err); throw new Exception("Unreachable code"); }
public static bool TrySetIndexRange(Session session, Table table, SetIndexRangeGrbit rangeFlags) { return Api.TrySetIndexRange(session, table, rangeFlags); }