Extension methods around DataRecord (DbNull and column name support)
Extension methods around DataRecord (DbNull and column name support)
IDataRecord Interface
namespace : System.Data
Provides access to the column values within each row for a DataReader
, and is implemented by .NET Framework data providers that access relational databases.
2 observations :
- methods take colum index as parameter. (
GetInt32(Int32)
,GetInt64(Int32)
, ...) - we must check if the specified field is set to null before retrieve value (
dataRecord.IsDBNull(colIndex)
oudataRecord[columnName] == DBNull.Value
)
Needs
- methods that provide access to the column value by name (
GetInt32(String)
,GetInt64(String)
, ...) - Nullable type to handle DbNull