Sunday, April 23, 2006

Mapping Data Provider Data Types

[.NET 2.0 Data Access]


We recommend that you use the typed accessor methods of the DataReader when you know the specific type of the value being returned. Typed accessor methods result in better performance by returning a value as a specific .NET Framework type, eliminating the need for additional type conversion. The SqlDataReader exposes SQL Server–specific typed accessor methods if a .NET Framework type does not meet the needs of the application. SQL Server–specific typed accessor methods return objects of System.Data.SqlTypes.” -- local MSDN


Above lines are extracted from MSDN which confirms that you should use accessors to read the data out of data readers and it will result better performance since it eliminates type casting. Further MSDN describes the getter names which you should use in SQL and Oracle provides for specific data type. So better to read section “Mapping Data Provider Data Types to .NET Framework Data Types” before reading values from datareaders.

No comments: