Method GetValues
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
GetValues(IDataRecord)
Reads the values of the current row into a new array sized to the record's FieldCount.
public static object[] GetValues(this IDataRecord record)
Parameters
recordIDataRecordThe record (typically a data reader positioned on a row) to read the values from.
Returns
- object[]
A new array containing the value of each column in ordinal order.
Exceptions
- ArgumentNullException
recordis null.
- See Also
GetValues(IDataRecord, int)
Reads the values of the current row into a new array of the specified length.
public static object[] GetValues(this IDataRecord record, int arrayLength)
Parameters
recordIDataRecordThe record (typically a data reader positioned on a row) to read the values from.
arrayLengthintThe size of the resultant array. If it is smaller than the field count, only that many leading values are copied; if it is larger, the extra elements are null.
Returns
- object[]
A new array containing the values in ordinal order.
Exceptions
- ArgumentNullException
recordis null.
GetValues(IDataRecord, int, ArrayPool<object>)
Reads the values of the current row into an array rented from arrayPool.
public static object[] GetValues(this IDataRecord record, int minimumArrayLength, ArrayPool<object> arrayPool)
Parameters
recordIDataRecordThe record (typically a data reader positioned on a row) to read the values from.
minimumArrayLengthintThe minimum size of the rented array. If it is smaller than the field count, only that many leading values are copied.
arrayPoolArrayPool<object>The array pool to rent the buffer from.
Returns
- object[]
The rented array containing the values in ordinal order.
Remarks
The caller owns the rented array and must return it to arrayPool. The array can be longer than requested, and elements beyond the copied values are not cleared, so they can hold values from earlier use. Because the array holds database values, consider returning it with its contents cleared.
Exceptions
- ArgumentNullException
recordorarrayPoolis null.
GetValues(IDataRecord, ArrayPool<object>)
Reads the values of the current row into an array rented from arrayPool, sized for the record's FieldCount.
public static object[] GetValues(this IDataRecord record, ArrayPool<object> arrayPool)
Parameters
recordIDataRecordThe record (typically a data reader positioned on a row) to read the values from.
arrayPoolArrayPool<object>The array pool to rent the buffer from.
Returns
- object[]
The rented array containing the values in ordinal order.
Remarks
The caller owns the rented array and must return it to arrayPool. The array can be longer than requested, and elements beyond the copied values are not cleared, so they can hold values from earlier use. Because the array holds database values, consider returning it with its contents cleared.
Exceptions
- ArgumentNullException
recordorarrayPoolis null.