Support for System.DBNull in bo.SetValue method


Author
Message
Edhy Rijo
E
StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent, Ben,
I am using more and more DevExpress controls and sometimes when hitting a DBNull value, the Business Object is not able to handle it, even though I have set the "NULL Value Option" in the BOM to "Return Alternante on Null = 0", but the SetValue(ByVal component As Object, ByVal value As Object) of the BO does not take System.DBNull into consideration.

For example, this line below, will throw an exception if the value is System.DBNull
 DirectCast(component, bizTransaction).FK_Vendor_Carrier = CType(value, System.Int32)

But if I change the bo.Designer to something like this, it will work just fine, but the bo.Designer will be overwritten next time I use the BOM.

 Case bizTransactionFieldNames.FK_Vendor_Carrier
                    If value Is Nothing OrElse IsDBNull(value) Then
                        DirectCast(component, bizTransaction).FK_Vendor_Carrier = 0
                    Else
                        DirectCast(component, bizTransaction).FK_Vendor_Carrier = CType(value, System.Int32)
                    End If


Is there a way to overcome this situation?


Edhy Rijo

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