StrataFrame Forum

About null values with ReturnAlternateOnNull results in "'MustInherit' or override" error message

http://forum.strataframe.net/Topic1306.aspx

By Kari Paukku - 5/31/2006

Hi,

In my BusinessObjects there are two fields that initially will be null. The fields are CREATED (DATE) and CREATED_BY (Char). In the Business Object Mapper these have been set to "Return Alternate On Null". The CREATED has the NULL replacement set to System.DateTime.Today. CREATED_BY has the same value set to String.Empty.

When compiling the application the following error is returned:

For the CREATED field the error message is

Error 1 Class 'Field_CREATED_Descriptor' must either be declared 'MustInherit' or override the following inherited 'MustOverride' member(s):
    System.ComponentModel.PropertyDescriptor : Public MustOverride Sub SetValue(component As Object, value As Object). File: BO_CompanyDetails.Designer.vb

and for the CREATED_BY the error is

Error 2 Class 'Field_CREATED_BY_Descriptor' must either be declared 'MustInherit' or override the following inherited 'MustOverride' member(s):
    System.ComponentModel.PropertyDescriptor : Public MustOverride Sub SetValue(component As Object, value As Object). FILE: BO_CompanyDetails.Designer.vb 

Any ideas how to fix this?

TIA,
Kari

ps. Is it possible to have the  CREATED -field to be null rather than the  System.DateTime.Today (The dartabase would take care of setting the value in case it's null)

By Kari Paukku - 5/31/2006

Hi,

I resolved(?) this. The conflict was caused by the fact that I had also checked the "Read Only" check box for the fields in questiion. Clearing that removed the error.

Sorry for the "red herring"

Kari

By StrataFrame Team - 5/31/2006

No, Kari, that's actually a bug... the SetValue method still needs to be overridden, even if the property is specified as ReadOnly. 

ps. Is it possible to have the  CREATED -field to be null rather than the  System.DateTime.Today (The dartabase would take care of setting the value in case it's null)

Yes, Kari, you can.  Basically, when you create a new record within the business object, the business object will initialize the fields within the new row so that there are no NULL values.  If you want all of the fields to be null, then you can set the AllowNullValues property on the business object to True, and the BO will not initialize the values (leaving the NULLs).  But, if you just want NULL values on those 2 fields, then your best bet is to do this:

Within the SetDefaultValues() event handler of the business object, put these 2 lines:

Me.CurrentRow.Item("Created") = DbNull.Value

Me.CurrentRow.Item("Created_By") = DbNull.Value

This will initialize those 2 fields with null values.  Your properties will still return the alternate values, but those null values will be saved back to the database.