I received an email from a Mr. Grimes asking if there are any performance issues with using generics to retrieve nullable data from a database. To answer his question: yes, and the hit on performance depends on two factors:
After perusing the source code for SqlDataReader, the "Get" methods (like GetInt32(), GetGuid(), ect) return the specified field’s value without a conversion operation; this is confirmed by MSDN (check the remarks section; OleDbDataReader and OdbcDataReader say the same thing). The code I posted last week uses the Item property to retrieve the field’s value (in C# the Item property is transparent, and you use it as an indexer. Example: dataReader[i]). This value is boxed and must be unboxed if you want to do anything other than display the string representation of the value. Boxing and unboxing are expensive operations, and performance begins to degrade the more they’re performed.
I tested my generic methods on a table with 119,000 records and three nullable fields. The test selects all records and reads the value of each field. My generic methods averaged 111ms slower than the appropriate "Get" methods to process all 119,000 records. It’s up to you to decide if that’s acceptable for your project; so use at your own discretion.