Ejemplo n.º 1
0
        /// <summary>
        /// Intersect a group of index ranges and return the bookmarks of the records which are found
        /// in all the index ranges.
        /// Also see <see cref="JetIntersectIndexes"/>.
        /// </summary>
        /// <param name="sesid">The session to use.</param>
        /// <param name="tableids">
        /// The tableids to use. Each tableid must be from a different index on the same table and
        /// have an active index range. Use <see cref="JetSetIndexRange"/>
        /// to create an index range.
        /// </param>
        /// <returns>
        /// The bookmarks of the records which are found in all the index ranges. The bookmarks
        /// are returned in primary key order.
        /// </returns>
        public static IEnumerable <byte[]> IntersectIndexes(JET_SESID sesid, params JET_TABLEID[] tableids)
        {
            if (null == tableids)
            {
                throw new ArgumentNullException("tableids");
            }

            JET_RECORDLIST recordlist;

            var ranges = new JET_INDEXRANGE[tableids.Length];

            for (int i = 0; i < tableids.Length; ++i)
            {
                ranges[i] = new JET_INDEXRANGE {
                    tableid = tableids[i]
                };
            }

            Api.JetIntersectIndexes(sesid, ranges, ranges.Length, out recordlist, IntersectIndexesGrbit.None);

            try
            {
                if (Api.TryMoveFirst(sesid, recordlist.tableid))
                {
                    do
                    {
                        yield return(Api.RetrieveColumn(sesid, recordlist.tableid, recordlist.columnidBookmark));
                    }while (Api.TryMoveNext(sesid, recordlist.tableid));
                }
            }
            finally
            {
                Api.JetCloseTable(sesid, recordlist.tableid);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Intersect a group of index ranges and return the bookmarks of the records which are found
        /// in all the index ranges. 
        /// Also see <see cref="JetIntersectIndexes"/>.
        /// </summary>
        /// <param name="sesid">The session to use.</param>
        /// <param name="tableids">
        /// The tableids to use. Each tableid must be from a different index on the same table and
        /// have an active index range. Use <see cref="JetSetIndexRange"/>
        /// to create an index range.
        /// </param>
        /// <returns>
        /// The bookmarks of the records which are found in all the index ranges. The bookmarks 
        /// are returned in primary key order.
        /// </returns>
        public static IEnumerable<byte[]> IntersectIndexes(JET_SESID sesid, params JET_TABLEID[] tableids)
        {
            if (null == tableids)
            {
                throw new ArgumentNullException("tableids");
            }

            JET_RECORDLIST recordlist;

            var ranges = new JET_INDEXRANGE[tableids.Length];
            for (int i = 0; i < tableids.Length; ++i)
            {
                ranges[i] = new JET_INDEXRANGE { tableid = tableids[i] };
            }

            Api.JetIntersectIndexes(sesid, ranges, ranges.Length, out recordlist, IntersectIndexesGrbit.None);

            try
            {
                Api.MoveBeforeFirst(sesid, recordlist.tableid);
                while (Api.TryMoveNext(sesid, recordlist.tableid))
                {
                    yield return Api.RetrieveColumn(sesid, recordlist.tableid, recordlist.columnidBookmark);
                }
            }
            finally
            {
                Api.JetCloseTable(sesid, recordlist.tableid);
            }
        }
Ejemplo n.º 3
0
 public void Setup()
 {
     this.managed = new JET_INDEXRANGE
     {
         tableid = new JET_TABLEID { Value = (IntPtr) 0x1234 },
         grbit = IndexRangeGrbit.RecordInIndex,
     };
     this.native = this.managed.GetNativeIndexRange();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Intersect a group of index ranges and return the bookmarks of the records which are found
        /// in all the index ranges. 
        /// Also see <see cref="JetIntersectIndexes"/>.
        /// </summary>
        /// <param name="sesid">The session to use.</param>
        /// <param name="tableids">
        /// The tableids to use. Each tableid must be from a different index on the same table and
        /// have an active index range. Use <see cref="JetSetIndexRange"/>
        /// to create an index range.
        /// </param>
        /// <returns>
        /// The bookmarks of the records which are found in all the index ranges. The bookmarks 
        /// are returned in primary key order.
        /// </returns>
        public static IEnumerable<byte[]> IntersectIndexes(JET_SESID sesid, params JET_TABLEID[] tableids)
        {
            if (null == tableids)
            {
                throw new ArgumentNullException("tableids");
            }

            var ranges = new JET_INDEXRANGE[tableids.Length];
            for (int i = 0; i < tableids.Length; ++i)
            {
                ranges[i] = new JET_INDEXRANGE { tableid = tableids[i] };
            }

            return new GenericEnumerable<byte[]>(() => new IntersectIndexesEnumerator(sesid, ranges));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Intersect a group of index ranges and return the bookmarks of the records which are found
        /// in all the index ranges.
        /// Also see <see cref="JetIntersectIndexes"/>.
        /// </summary>
        /// <param name="sesid">The session to use.</param>
        /// <param name="tableids">
        /// The tableids to use. Each tableid must be from a different index on the same table and
        /// have an active index range. Use <see cref="JetSetIndexRange"/>
        /// to create an index range.
        /// </param>
        /// <returns>
        /// The bookmarks of the records which are found in all the index ranges. The bookmarks
        /// are returned in primary key order.
        /// </returns>
        public static IEnumerable <byte[]> IntersectIndexes(JET_SESID sesid, params JET_TABLEID[] tableids)
        {
            if (null == tableids)
            {
                throw new ArgumentNullException("tableids");
            }

            var ranges = new JET_INDEXRANGE[tableids.Length];

            for (int i = 0; i < tableids.Length; ++i)
            {
                ranges[i] = new JET_INDEXRANGE {
                    tableid = tableids[i]
                };
            }

            return(new GenericEnumerable <byte[]>(() => new IntersectIndexesEnumerator(sesid, ranges)));
        }
Ejemplo n.º 6
0
 public void VerifyIndexRangeConstructorSetsGrbit()
 {
     var indexrange = new JET_INDEXRANGE();
     Assert.AreEqual(IndexRangeGrbit.RecordInIndex, indexrange.grbit);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Computes the intersection between multiple sets of index entries from different secondary
 /// indices over the same table. This operation is useful for finding the set of records in a
 /// table that match two or more criteria that can be expressed using index ranges. Also see
 /// <seealso cref="IntersectIndexes"/>.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="ranges">
 /// An the index ranges to intersect. The tableids in the ranges
 /// must have index ranges set on them. Use <see cref="JetSetIndexRange"/>
 /// to create an index range.
 /// </param>
 /// <param name="numRanges">
 /// The number of index ranges.
 /// </param>
 /// <param name="recordlist">
 /// Returns information about the temporary table containing the intersection results.
 /// </param>
 /// <param name="grbit">Intersection options.</param>
 public static void JetIntersectIndexes(
     JET_SESID sesid,
     JET_INDEXRANGE[] ranges,
     int numRanges,
     out JET_RECORDLIST recordlist,
     IntersectIndexesGrbit grbit)
 {
     Api.Check(Impl.JetIntersectIndexes(sesid, ranges, numRanges, out recordlist, grbit));
 }
Ejemplo n.º 8
0
        public void JetIntersectIndexesThrowsExceptionWhenIntersectingOneTableid()
        {
            var ranges = new JET_INDEXRANGE[1];
            ranges[0] = new JET_INDEXRANGE { tableid = this.tableid };

            JET_RECORDLIST recordlist;
            Api.JetIntersectIndexes(this.sesid, ranges, 1, out recordlist, IntersectIndexesGrbit.None);
        }
Ejemplo n.º 9
0
        public void VerifyJetIntersectIndexesReturnsCorrectNumberOfRecords()
        {
            JET_TABLEID tableid1 = this.OpenTable();
            JET_TABLEID tableid2 = this.OpenTable();

            Api.JetSetCurrentIndex(this.sesid, tableid1, "index1");
            this.SetIndexRange(tableid1, 4, 6);

            Api.JetSetCurrentIndex(this.sesid, tableid2, "index2");
            this.SetIndexRange(tableid2, 1, 3);

            var ranges = new JET_INDEXRANGE[2];
            ranges[0] = new JET_INDEXRANGE { tableid = tableid1 };
            ranges[1] = new JET_INDEXRANGE { tableid = tableid2 };

            JET_RECORDLIST recordlist;
            Api.JetIntersectIndexes(this.sesid, ranges, 2, out recordlist, IntersectIndexesGrbit.None);

            Assert.AreEqual(9, recordlist.cRecords);
            Api.JetCloseTable(this.sesid, recordlist.tableid);
        }
Ejemplo n.º 10
0
 public void JetIndexrangeToString()
 {
     var indexrange = new JET_INDEXRANGE { grbit = IndexRangeGrbit.RecordInIndex };
     Assert.AreEqual("JET_INDEXRANGE(0x0,RecordInIndex)", indexrange.ToString());
 }