Framework Design Guidelines: System.DBNull
Continuing in our weekly blog post series that highlights a few of the new additions to the Framework Design Guidelines 2nd edition.. This content is found in the Nullable<T> section of Chapter 8: Usage Guidelines. Pablo helps us out with some subtle details that might really come in handy.
AVOID using System.DBNull. Prefer Nullable<T> instead.
Nullable<T> is in general a better representation of optional database values. One thing to consider though is that while Nullable<T> gives you the ability to represent null values, you don’t get database null operational semantics. Specifically, you don’t get null propagation through operators and functions. If you deeply care about the propagation semantics, consider sticking with DBNull.
Comments
Anonymous
February 09, 2009
PingBack from http://www.clickandsolve.com/?p=5573Anonymous
February 09, 2009
Continuing in our weekly blog post series that highlights a few of the new additions to the FrameworkAnonymous
February 09, 2009
null propagation is a language feature though, not a platform one. Our compiler (Delphi Prism) does do null propagation when using nullable types expressions.Anonymous
February 10, 2009
Thank you for submitting this cool story - Trackback from DotNetShoutoutAnonymous
February 10, 2009
an example of each would have been greatAnonymous
February 11, 2009
LINQ to SQL knocks out some of these issues right? My dbml objects come over as Nullable.Anonymous
February 16, 2009
DDD/ALT.NET Casey has written a bunch more in his DDD series since my last update 4) DDD: There Is No Database 5) DDD: Command Query Separation as an Architectural Concept 6) DDD: Entities and Value Objects 7) DDD: Where is the Code? 8) DDD: Download