public void VerifyUpdateFromNativeRetrievecolumnSetsCbactual() { var setcolumn = new JET_RETRIEVECOLUMN(); var native = new NATIVE_RETRIEVECOLUMN { cbActual = 0x100 }; setcolumn.UpdateFromNativeRetrievecolumn(native); Assert.AreEqual(0x100, setcolumn.cbActual); }
/// <summary> /// Gets the NATIVE_RETRIEVECOLUMN structure that represents the object. /// </summary> /// <param name="retrievecolumn">The NATIVE_RETRIEVECOLUMN structure to fill in.</param> /// <remarks> /// This takes a reference because a NATIVE_RETRIEVECOLUMN is quite large (40 bytes) /// so copying it around can be expensive. /// </remarks> internal void GetNativeRetrievecolumn(ref NATIVE_RETRIEVECOLUMN retrievecolumn) { retrievecolumn.columnid = this.columnid.Value; retrievecolumn.cbData = unchecked ((uint)this.cbData); // guaranteed to not be negative retrievecolumn.grbit = (uint)this.grbit; retrievecolumn.ibLongValue = checked ((uint)this.ibLongValue); retrievecolumn.itagSequence = checked ((uint)this.itagSequence); }
/// <summary> /// Update the output members of the class from a NATIVE_RETRIEVECOLUMN /// structure. This should be done after the columns are retrieved. /// </summary> /// <param name="native"> /// The structure containing the updated output fields. /// </param> internal void UpdateFromNativeRetrievecolumn(NATIVE_RETRIEVECOLUMN native) { this.cbActual = checked ((int)native.cbActual); this.columnidNextTagged = new JET_COLUMNID { Value = native.columnidNextTagged }; this.err = (JET_wrn)native.err; }
public void Setup() { this.managed = new JET_RETRIEVECOLUMN { cbData = 1, columnid = new JET_COLUMNID { Value = 2 }, grbit = RetrieveColumnGrbit.RetrieveCopy, ibLongValue = 3, itagSequence = 4, }; this.native = this.managed.GetNativeRetrievecolumn(); }
/// <summary> /// Gets the NATIVE_RETRIEVECOLUMN structure that represents the object. /// </summary> /// <returns>A NATIVE_RETRIEVECOLUMN structure whose fields match the class.</returns> internal NATIVE_RETRIEVECOLUMN GetNativeRetrievecolumn() { var retrievecolumn = new NATIVE_RETRIEVECOLUMN { columnid = this.columnid.Value, cbData = checked ((uint)this.cbData), grbit = (uint)this.grbit, ibLongValue = checked ((uint)this.ibLongValue), itagSequence = checked ((uint)this.itagSequence), }; return(retrievecolumn); }
/// <summary> /// Update the output members of the class from a NATIVE_RETRIEVECOLUMN /// structure. This should be done after the columns are retrieved. /// </summary> /// <param name="native"> /// The structure containing the updated output fields. /// </param> internal void UpdateFromNativeRetrievecolumn(NATIVE_RETRIEVECOLUMN native) { this.cbActual = checked((int)native.cbActual); this.columnidNextTagged = new JET_COLUMNID { Value = native.columnidNextTagged }; this.err = (JET_wrn) native.err; }
/// <summary> /// Gets the NATIVE_RETRIEVECOLUMN structure that represents the object. /// </summary> /// <returns>A NATIVE_RETRIEVECOLUMN structure whose fields match the class.</returns> internal NATIVE_RETRIEVECOLUMN GetNativeRetrievecolumn() { var retrievecolumn = new NATIVE_RETRIEVECOLUMN { columnid = this.columnid.Value, cbData = checked((uint)this.cbData), grbit = (uint)this.grbit, ibLongValue = checked((uint)this.ibLongValue), itagSequence = checked((uint)this.itagSequence), }; return retrievecolumn; }
/// <summary> /// Create a native RetrieveColumn from this object. /// </summary> /// <param name="retrievecolumn"> /// The retrieve column structure to fill in. /// </param> private void MakeNativeRetrieveColumn(ref NATIVE_RETRIEVECOLUMN retrievecolumn) { retrievecolumn.columnid = this.Columnid.Value; retrievecolumn.grbit = (uint)this.RetrieveGrbit; retrievecolumn.itagSequence = checked((uint)this.ItagSequence); }
/// <summary> /// Retrieve the value for columns whose buffers were truncated. /// </summary> /// <param name="sesid">The session to use.</param> /// <param name="tableid">The table to use.</param> /// <param name="columnValues">The column values.</param> /// <param name="nativeRetrievecolumns"> /// The native retrieve columns that match the column values. /// </param> private static unsafe void RetrieveTruncatedBuffers(JET_SESID sesid, JET_TABLEID tableid, IList<ColumnValue> columnValues, NATIVE_RETRIEVECOLUMN* nativeRetrievecolumns) { for (int i = 0; i < columnValues.Count; ++i) { if (nativeRetrievecolumns[i].err == (int)JET_wrn.BufferTruncated) { var buffer = new byte[nativeRetrievecolumns[i].cbActual]; int actualSize; int err; var retinfo = new JET_RETINFO { itagSequence = columnValues[i].ItagSequence }; // Pin the buffer and retrieve the data fixed (byte* pinnedBuffer = buffer) { err = Api.Impl.JetRetrieveColumn( sesid, tableid, columnValues[i].Columnid, new IntPtr(pinnedBuffer), buffer.Length, out actualSize, columnValues[i].RetrieveGrbit, retinfo); } // Throw errors, but put warnings in the structure Api.Check(err); columnValues[i].Error = (JET_wrn)err; // For BytesColumnValue this will copy the data to a new array. // If this situation becomes common we should simply use the array. columnValues[i].GetValueFromBytes(buffer, 0, actualSize, err); } } }
/// <summary> /// Gets the NATIVE_RETRIEVECOLUMN structure that represents the object. /// </summary> /// <param name="retrievecolumn">The NATIVE_RETRIEVECOLUMN structure to fill in.</param> /// <remarks> /// This takes a reference because a NATIVE_RETRIEVECOLUMN is quite large (40 bytes) /// so copying it around can be expensive. /// </remarks> internal void GetNativeRetrievecolumn(ref NATIVE_RETRIEVECOLUMN retrievecolumn) { retrievecolumn.columnid = this.columnid.Value; retrievecolumn.cbData = unchecked((uint)this.cbData); // guaranteed to not be negative retrievecolumn.grbit = (uint)this.grbit; retrievecolumn.ibLongValue = checked((uint)this.ibLongValue); retrievecolumn.itagSequence = checked((uint)this.itagSequence); }
public void VerifyUpdateFromNativeRetrievecolumnSetsColumnidNextTagged() { var setcolumn = new JET_RETRIEVECOLUMN(); var native = new NATIVE_RETRIEVECOLUMN { columnidNextTagged = 0x20 }; setcolumn.UpdateFromNativeRetrievecolumn(native); var expected = new JET_COLUMNID { Value = 0x20 }; Assert.AreEqual(expected, setcolumn.columnidNextTagged); }
public void VerifyUpdateFromNativeRetrievecolumnSetsErr() { var setcolumn = new JET_RETRIEVECOLUMN(); var native = new NATIVE_RETRIEVECOLUMN { err = 1004 }; setcolumn.UpdateFromNativeRetrievecolumn(native); Assert.AreEqual(JET_wrn.ColumnNull, setcolumn.err); }
/// <summary> /// Create a native RetrieveColumn from this object. /// </summary> /// <param name="retrievecolumn"> /// The retrieve column structure to fill in. /// </param> private void MakeNativeRetrieveColumn(ref NATIVE_RETRIEVECOLUMN retrievecolumn) { retrievecolumn.columnid = this.Columnid.Value; retrievecolumn.grbit = (uint)this.RetrieveGrbit; retrievecolumn.itagSequence = checked ((uint)this.ItagSequence); }
public void VerifyUpdateFromNativeRetrievecolumnSetsItagSequence() { var setcolumn = new JET_RETRIEVECOLUMN(); var native = new NATIVE_RETRIEVECOLUMN { itagSequence = 7 }; setcolumn.UpdateFromNativeRetrievecolumn(ref native); Assert.AreEqual(7, setcolumn.itagSequence); }