/// <summary> /// Set an array of simple filters for <see cref="Api.JetMove(JET_SESID,JET_TABLEID,int,MoveGrbit)"/> /// </summary> /// <param name="sesid">The session to use for the call.</param> /// <param name="tableid">The cursor to position.</param> /// <param name="filters">Simple record filters.</param> /// <param name="grbit">Move options.</param> /// <returns>An error if the call fails.</returns> public int JetSetCursorFilter(JET_SESID sesid, JET_TABLEID tableid, JET_INDEX_COLUMN[] filters, CursorFilterGrbit grbit) { TraceFunctionCall(); this.CheckSupportsWindows8Features("JetSetCursorFilter"); if (filters == null || filters.Length == 0) { return(Err(NativeMethods.JetSetCursorFilter(sesid.Value, tableid.Value, null, 0, checked ((uint)grbit)))); } var handles = new GCHandleCollection(); try { NATIVE_INDEX_COLUMN[] nativeFilters = new NATIVE_INDEX_COLUMN[filters.Length]; for (int i = 0; i < filters.Length; i++) { nativeFilters[i] = filters[i].GetNativeIndexColumn(ref handles); } return(Err(NativeMethods.JetSetCursorFilter(sesid.Value, tableid.Value, nativeFilters, (uint)filters.Length, checked ((uint)grbit)))); } finally { handles.Dispose(); } }
/// <summary> /// Creates indexes over data in an ESE database. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The table to create the index on.</param> /// <param name="indexcreates">Array of objects describing the indexes to be created.</param> /// <param name="numIndexCreates">Number of index description objects.</param> /// <returns>An error code.</returns> private static int CreateIndexes3(JET_SESID sesid, JET_TABLEID tableid, IList <JET_INDEXCREATE> indexcreates, int numIndexCreates) { // pin the memory var handles = new GCHandleCollection(); try { NATIVE_INDEXCREATE3[] nativeIndexcreates = GetNativeIndexCreate3s(indexcreates, ref handles); return(Err(NativeMethods.JetCreateIndex4W(sesid.Value, tableid.Value, nativeIndexcreates, checked ((uint)numIndexCreates)))); } finally { handles.Dispose(); } }
/// <summary> /// If the records with the specified key rangess are not in the buffer /// cache, then start asynchronous reads to bring the records into the /// database buffer cache. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The table to issue the prereads against.</param> /// <param name="indexRanges">The key ranges to preread.</param> /// <param name="rangeIndex">The index of the first key range in the array to read.</param> /// <param name="rangeCount">The maximum number of key ranges to preread.</param> /// <param name="rangesPreread">Returns the number of keys actually preread.</param> /// <param name="columnsPreread">List of column ids for long value columns to preread.</param> /// <param name="grbit">Preread options. Used to specify the direction of the preread.</param> /// <returns> /// An error if the call fails. /// </returns> public int JetPrereadIndexRanges( JET_SESID sesid, JET_TABLEID tableid, JET_INDEX_RANGE[] indexRanges, int rangeIndex, int rangeCount, out int rangesPreread, JET_COLUMNID[] columnsPreread, PrereadIndexRangesGrbit grbit) { TraceFunctionCall(); this.CheckSupportsWindows8Features("JetPrereadIndexRanges"); CheckNotNull(indexRanges, "indexRanges"); CheckDataSize(indexRanges, rangeIndex, "rangeIndex", rangeCount, "rangeCount"); var handles = new GCHandleCollection(); try { NATIVE_INDEX_RANGE[] nativeRanges = new NATIVE_INDEX_RANGE[rangeCount]; for (int i = 0; i < rangeCount; i++) { nativeRanges[i] = indexRanges[i + rangeIndex].GetNativeIndexRange(ref handles); } if (columnsPreread != null) { var nativecolumnids = new uint[columnsPreread.Length]; for (int i = 0; i < columnsPreread.Length; i++) { nativecolumnids[i] = (uint)columnsPreread[i].Value; } return(Err(NativeMethods.JetPrereadIndexRanges(sesid.Value, tableid.Value, nativeRanges, (uint)rangeCount, out rangesPreread, nativecolumnids, (uint)columnsPreread.Length, checked ((uint)grbit)))); } else { return(Err(NativeMethods.JetPrereadIndexRanges(sesid.Value, tableid.Value, nativeRanges, (uint)rangeCount, out rangesPreread, null, (uint)0, checked ((uint)grbit)))); } } finally { handles.Dispose(); } }
/// <summary> /// Creates a table, adds columns, and indices on that table. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="dbid">The database to which to add the new table.</param> /// <param name="tablecreate">Object describing the table to create.</param> /// <returns>An error if the call fails.</returns> private static int CreateTableColumnIndex4( JET_SESID sesid, JET_DBID dbid, JET_TABLECREATE tablecreate) { NATIVE_TABLECREATE4 nativeTableCreate = tablecreate.GetNativeTableCreate4(); unsafe { var handles = new GCHandleCollection(); try { // Convert/pin the column definitions. nativeTableCreate.rgcolumncreate = (NATIVE_COLUMNCREATE *)GetNativeColumnCreates(tablecreate.rgcolumncreate, true, ref handles); // Convert/pin the index definitions. NATIVE_INDEXCREATE3[] nativeIndexCreates = GetNativeIndexCreate3s(tablecreate.rgindexcreate, ref handles); nativeTableCreate.rgindexcreate = handles.Add(nativeIndexCreates); // Convert/pin the space hints. if (tablecreate.pSeqSpacehints != null) { NATIVE_SPACEHINTS nativeSpaceHints = tablecreate.pSeqSpacehints.GetNativeSpaceHints(); nativeTableCreate.pSeqSpacehints = (NATIVE_SPACEHINTS *)handles.Add(nativeSpaceHints); } if (tablecreate.pLVSpacehints != null) { NATIVE_SPACEHINTS nativeSpaceHints = tablecreate.pLVSpacehints.GetNativeSpaceHints(); nativeTableCreate.pLVSpacehints = (NATIVE_SPACEHINTS *)handles.Add(nativeSpaceHints); } int err = NativeMethods.JetCreateTableColumnIndex4W(sesid.Value, dbid.Value, ref nativeTableCreate); // Modified fields. tablecreate.tableid = new JET_TABLEID { Value = nativeTableCreate.tableid }; tablecreate.cCreated = checked ((int)nativeTableCreate.cCreated); if (tablecreate.rgcolumncreate != null) { for (int i = 0; i < tablecreate.rgcolumncreate.Length; ++i) { tablecreate.rgcolumncreate[i].SetFromNativeColumnCreate(ref nativeTableCreate.rgcolumncreate[i]); } } if (tablecreate.rgindexcreate != null) { for (int i = 0; i < tablecreate.rgindexcreate.Length; ++i) { tablecreate.rgindexcreate[i].SetFromNativeIndexCreate(ref nativeIndexCreates[i]); } } return(Err(err)); } finally { handles.Dispose(); } } }
/// <summary> /// Creates a table, adds columns, and indices on that table. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="dbid">The database to which to add the new table.</param> /// <param name="tablecreate">Object describing the table to create.</param> /// <returns>An error if the call fails.</returns> private static int CreateTableColumnIndex4( JET_SESID sesid, JET_DBID dbid, JET_TABLECREATE tablecreate) { NATIVE_TABLECREATE4 nativeTableCreate = tablecreate.GetNativeTableCreate4(); unsafe { var handles = new GCHandleCollection(); try { // Convert/pin the column definitions. nativeTableCreate.rgcolumncreate = (NATIVE_COLUMNCREATE*)GetNativeColumnCreates(tablecreate.rgcolumncreate, true, ref handles); // Convert/pin the index definitions. NATIVE_INDEXCREATE3[] nativeIndexCreates = GetNativeIndexCreate3s(tablecreate.rgindexcreate, ref handles); nativeTableCreate.rgindexcreate = handles.Add(nativeIndexCreates); // Convert/pin the space hints. if (tablecreate.pSeqSpacehints != null) { NATIVE_SPACEHINTS nativeSpaceHints = tablecreate.pSeqSpacehints.GetNativeSpaceHints(); nativeTableCreate.pSeqSpacehints = (NATIVE_SPACEHINTS*)handles.Add(nativeSpaceHints); } if (tablecreate.pLVSpacehints != null) { NATIVE_SPACEHINTS nativeSpaceHints = tablecreate.pLVSpacehints.GetNativeSpaceHints(); nativeTableCreate.pLVSpacehints = (NATIVE_SPACEHINTS*)handles.Add(nativeSpaceHints); } int err = NativeMethods.JetCreateTableColumnIndex4W(sesid.Value, dbid.Value, ref nativeTableCreate); // Modified fields. tablecreate.tableid = new JET_TABLEID { Value = nativeTableCreate.tableid }; tablecreate.cCreated = checked((int)nativeTableCreate.cCreated); if (tablecreate.rgcolumncreate != null) { for (int i = 0; i < tablecreate.rgcolumncreate.Length; ++i) { tablecreate.rgcolumncreate[i].SetFromNativeColumnCreate(nativeTableCreate.rgcolumncreate[i]); } } if (tablecreate.rgindexcreate != null) { for (int i = 0; i < tablecreate.rgindexcreate.Length; ++i) { tablecreate.rgindexcreate[i].SetFromNativeIndexCreate(nativeIndexCreates[i]); } } return Err(err); } finally { handles.Dispose(); } } }
/// <summary> /// Creates indexes over data in an ESE database. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The table to create the index on.</param> /// <param name="indexcreates">Array of objects describing the indexes to be created.</param> /// <param name="numIndexCreates">Number of index description objects.</param> /// <returns>An error code.</returns> private static int CreateIndexes3(JET_SESID sesid, JET_TABLEID tableid, IList<JET_INDEXCREATE> indexcreates, int numIndexCreates) { // pin the memory var handles = new GCHandleCollection(); try { NATIVE_INDEXCREATE3[] nativeIndexcreates = GetNativeIndexCreate3s(indexcreates, ref handles); return Err(NativeMethods.JetCreateIndex4W(sesid.Value, tableid.Value, nativeIndexcreates, checked((uint)numIndexCreates))); } finally { handles.Dispose(); } }
/// <summary> /// Set an array of simple filters for <see cref="Api.JetMove(JET_SESID,JET_TABLEID,int,MoveGrbit)"/> /// </summary> /// <param name="sesid">The session to use for the call.</param> /// <param name="tableid">The cursor to position.</param> /// <param name="filters">Simple record filters.</param> /// <param name="grbit">Move options.</param> /// <returns>An error if the call fails.</returns> public int JetSetCursorFilter(JET_SESID sesid, JET_TABLEID tableid, JET_INDEX_COLUMN[] filters, CursorFilterGrbit grbit) { TraceFunctionCall("JetSetCursorFilter"); this.CheckSupportsWindows8Features("JetSetCursorFilter"); if (filters == null || filters.Length == 0) { return Err(NativeMethods.JetSetCursorFilter(sesid.Value, tableid.Value, null, 0, checked((uint)grbit))); } var handles = new GCHandleCollection(); try { NATIVE_INDEX_COLUMN[] nativeFilters = new NATIVE_INDEX_COLUMN[filters.Length]; for (int i = 0; i < filters.Length; i++) { nativeFilters[i] = filters[i].GetNativeIndexColumn(ref handles); } return Err(NativeMethods.JetSetCursorFilter(sesid.Value, tableid.Value, nativeFilters, (uint)filters.Length, checked((uint)grbit))); } finally { handles.Dispose(); } }
/// <summary> /// If the records with the specified key rangess are not in the buffer /// cache, then start asynchronous reads to bring the records into the /// database buffer cache. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The table to issue the prereads against.</param> /// <param name="indexRanges">The key rangess to preread.</param> /// <param name="rangeIndex">The index of the first key range in the array to read.</param> /// <param name="rangeCount">The maximum number of key ranges to preread.</param> /// <param name="rangesPreread">Returns the number of keys actually preread.</param> /// <param name="columnsPreread">List of column ids for long value columns to preread.</param> /// <param name="grbit">Preread options. Used to specify the direction of the preread.</param> /// <returns> /// An error if the call fails. /// </returns> public int JetPrereadIndexRanges( JET_SESID sesid, JET_TABLEID tableid, JET_INDEX_RANGE[] indexRanges, int rangeIndex, int rangeCount, out int rangesPreread, JET_COLUMNID[] columnsPreread, PrereadIndexRangesGrbit grbit) { TraceFunctionCall("JetPrereadIndexRanges"); this.CheckSupportsWindows8Features("JetPrereadIndexRanges"); CheckNotNull(indexRanges, "indexRanges"); CheckDataSize(indexRanges, rangeIndex, "rangeIndex", rangeCount, "rangeCount"); var handles = new GCHandleCollection(); try { NATIVE_INDEX_RANGE[] nativeRanges = new NATIVE_INDEX_RANGE[rangeCount]; for (int i = 0; i < rangeCount; i++) { nativeRanges[i] = indexRanges[i + rangeIndex].GetNativeIndexRange(ref handles); } if (columnsPreread != null) { var nativecolumnids = new uint[columnsPreread.Length]; for (int i = 0; i < columnsPreread.Length; i++) { nativecolumnids[i] = (uint)columnsPreread[i].Value; } return Err(NativeMethods.JetPrereadIndexRanges(sesid.Value, tableid.Value, nativeRanges, (uint)rangeCount, out rangesPreread, nativecolumnids, (uint)columnsPreread.Length, checked((uint)grbit))); } else { return Err(NativeMethods.JetPrereadIndexRanges(sesid.Value, tableid.Value, nativeRanges, (uint)rangeCount, out rangesPreread, null, (uint)0, checked((uint)grbit))); } } finally { handles.Dispose(); } }