Nullable Data Readers

I recently submitted an article about Nullable Data Readers .NET 2.0 for review which was posted here:

http://www.codeproject.com/Articles/12778/C-Nullable-Data-Readers

As a quick supplemental example for that article, suppose you have a non-nullable type in your business object that you're populating with from a nullable field in the database (this might also happen when populated from an outer join). This is a good opportunity to use the new nullable coalesce operator (aka, conditional assignmenet) in C# 2.0 like this:

someObject.IsActive = dr.GetNullableBoolean("IsActive") ?? false;
Tweet Post Share Update Email RSS