BO Mapper - Custom Field Properties (NULL Value Option)


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, Peter is right.  Any structure is a value type, and by definition, always has a value (you will never get a NullReferenceException by referencing a value type variable in code...).  Reference types are classes, and the variable only stores a reference to the object, not the actual object, so the reference can be a null pointer (allowing you to get a NullReferenceException).  So, Peter is right: simple types are all value types, while classes are all reference types.  You can always tell by opening the Object Browser in VS (View -> Object Browser) and looking at the icon next to the type.

You will notice that the symbol next to the IntXX types indicates a simple type, which is always a value type.  Also, the symbol next to IntPtr is thicker, which represents a structure, which is also a value type.  The thinner symbol next to the exception types indicates that the types are classes, which are reference types.

You'll also notice that when you expand the plus sign beside the value types, they all inherit from System.ValueType.  You cannot directly inherit from ValueType (I don't think...), but the compiler automatically does this when you define something as a structure (the same way a class you define automatically inherits from System.Object).

Hope that helps explain things some more Smile

choyt
choyt
StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)
Group: Forum Members
Posts: 78, Visits: 246
Thanks Peter...that does indeed help!
Peter Denton
Peter Denton
StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)StrataFrame Novice (111 reputation)
Group: Forum Members
Posts: 77, Visits: 787
G'day

Value Types are those that derive from the ValueType Class, and are allocated on the Stack and therefore are deallocated as soon as they go out of scope. They include Boolean, Byte, Char, Decimal, Single, Double, all the integer types, DateTime, Guid, Timespan.

Reference Types are allocated on the heap and are cleaned up by garbage collection. They include String, Array etc.

Hope this helps

Peter

choyt
choyt
StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)StrataFrame Novice (98 reputation)
Group: Forum Members
Posts: 78, Visits: 246
Ok...time for a really stupid question...(and boy do I feel stupid asking this)...but which datatypes are value and which are reference? I understand that only Value types can be null so I'm guessing that a Date is a reference and an Int32 would be value?

Thanks!

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, Peter is right.  The "Return Alternate on NULL" option only returned an alternate value if there was a DBNull.Value in the database.  However, if you set the property back to your alternate value, that alternate value was placed in the DataTable (not a DBNull.Value value). 

With the "Return Alternate on Null / Set Null on Alternate" options, it works the same as the above with a Get (the alternate is returned in the case of the DBNull.Value in the DataTable); however, the Set now tests the incoming value and if it equals the alternate value, DBNull.Value is copied into the DataTable.

The difference between the (reference type) and (value type) options really only affects VB.  When you specify the value type option, the = operator is used to compare the alternate value to the incoming value for the Set; with the reference type option, the "Is" operator is used to compare the alternate value to the incoming value.  With C#, both values do the same thing... since the "is" keyword is not a comparison operator like it is in VB; in C#, the "==" operator is used for both.  So, generally, you're going to want to use the (value type) option.  Only in a few cases in VB are you actually going to want to use the "Is" operator to compare your alternate to the value.

Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi,

Having just gone down this path I can offer this insight - it enables you to propergate nulls into your database. In my case I have the alternate value of string.empty for nullable string fields. By using these new options if the form control for the column is 'blanked out' then Null is saved to the database rather than "".

Cheers, Peter

Tim Dol
Tim Dol
StrataFrame User (446 reputation)StrataFrame User (446 reputation)StrataFrame User (446 reputation)StrataFrame User (446 reputation)StrataFrame User (446 reputation)StrataFrame User (446 reputation)StrataFrame User (446 reputation)StrataFrame User (446 reputation)StrataFrame User (446 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
In 1.6 I noticed two new 'NULL Value Options' in customer field properties (BO Mapper). I don't see these explained in the documentation. Can you explain how to use them?

1) Return Alternate on Null / Set Null on Alternate (reference type)

2) Return Alternate on Null / Set Null on Alternate (value type)

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search