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


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
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.

Kari Paukku
Kari Paukku
StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)
Group: Forum Members
Posts: 65, Visits: 820
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

Kari Paukku
Kari Paukku
StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)
Group: Forum Members
Posts: 65, Visits: 820
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)

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