Extending an Entity class

Posts   
 
    
trevorg
User
Posts: 104
Joined: 15-Nov-2007
# Posted on: 06-Mar-2008 23:23:32   

I would like to add code in the Save event to manually assign a sequence value to the primary key if it has not already been set. (I must do it this way rather than doing it properly via configuration in the designer).

The cleanest way would seem to be a partial class that would override the appropriate Save method(s), ie:

Partial Public Class EVENTEntity
    Public Overrides Function Save() As Boolean()
        If EVENT_ID = 0 Then
            ActionProcedures.SEQ_EVENT_ID_NEXTVAL(EVENT_ID)
        End If
        MyBase.Save()
    End Function
End Class

However, I get the error: 'Public Overrides Function Save() As Boolean()' cannot override 'Public Function Save() As Boolean' because it is not declared 'Overridable'.

Is there a way around this, or is there a better way of doing it?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 07-Mar-2008 10:19:13   

Use OnSave() rather than Save().