'Primitive type' as int can't be nullable, in the V2 of .NET they could. There also an open source  librairy that add support for that.
 
I always init my field/property to int.MinValue (magic number) for int ... and use iBATIS nullValue replacement.
 
-Gilles
 
On 8/25/05, Clinton Begin <[EMAIL PROTECTED]> wrote:
Hey guys,

Who would have thought that I would post a question to the user forum eh? 

My question is:  What's the deal with non-nullable "primitive" types in C# ?  Like seriously, Int32 extends Object (via struct?), and it's a class......so why can't it be set to null? 

Whoops, that's a question for Microsoft.  :-)

Anyway, a better question for this list is:  What pattern do you use to represent NULL types from the database.  That is, say you have an NUMERIC NULL field, and you want to map it to a class with a field/property of type int (Int32).  It won't work because int can't represent null.  So ...

Do you?

A) Write your own "NullableInt32" class and use a more complex mapping?

B) Use null value replacement and set the primitive to a magic number?

C) Something else?

Thanks much!

Clinton

Reply via email to