Table of Contents

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

record IDataRecord

The 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

record is 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

record IDataRecord

The record (typically a data reader positioned on a row) to read the values from.

arrayLength int

The 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

record is 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

record IDataRecord

The record (typically a data reader positioned on a row) to read the values from.

minimumArrayLength int

The minimum size of the rented array. If it is smaller than the field count, only that many leading values are copied.

arrayPool ArrayPool<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

record or arrayPool is 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

record IDataRecord

The record (typically a data reader positioned on a row) to read the values from.

arrayPool ArrayPool<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

record or arrayPool is null.