How do I override the overridable properties?

Posts   
 
    
JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 20-Dec-2006 11:34:28   

I have upgraded from 1.1 to 2.0 and I am now using VS2005 rather than VB.NET 2003

I had the following custom code in my entity:

Public Overrides Property durationofstay() As Integer
    Get
        Return MyBase.DurationOfStay
    End Get
    Set(ByVal Value As Integer)
        'If Me.CheckOut <> Me.CheckIn.AddDays(Value) Then
        If Value > 0 Then
            Me.CheckOut = Me.CheckIn.AddDays(Value)
            MyBase.DurationOfStay = Value
            Me.AmendNightRoomRates()
        Else
            MyBase.DurationOfStay = 0
        End If

        'End If

    End Set
End Property

Now if I paste that into my new project, I get the error property 'durationofstay' cannot be declared 'Overrides' because it does not override a property in a base class.

I have tried looking through the help files and doing searches and I didn't find much other than I can't add my own custom code areas which was one thought I had...

Any help would be greatly appreciated.

Cheers,

James

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 20-Dec-2006 11:49:44   

I think this is a casing problem.

'durationofstay'

isn't equal to the name generated in the entity, as entity field names never start with a lowercase character. Perhaps the vb.net 2005 compiler got more strict in this. Could you check that for me please?

Frans Bouma | Lead developer LLBLGen Pro
JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 20-Dec-2006 11:55:54   

If I change it to DurationOfStay it gives me the same message. The following generated code is in the same source file I put my bit into...

Public Overridable Property [DurationOfStay]() As System.Int32
    Get
        Dim valueToReturn As Object = MyBase.GetCurrentFieldValue(CType(BookingDetailFieldIndex.DurationOfStay, Integer))
        If valueToReturn Is Nothing Then
            valueToReturn = TypeDefaultValue.GetDefaultValue(GetType(System.Int32))
        End If
        Return CType(valueToReturn, System.Int32)
    End Get
    Set
        SetNewFieldValue(CType(BookingDetailFieldIndex.DurationOfStay, Integer), value)
    End Set
End Property

I also get the error 'Public Overridable Property DurationOfStay() As Integer' has multiple definitions with identical signatures against this section of code.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 20-Dec-2006 12:06:37   

Selfservicing? If so, add your own code to the base class of the generated entity base class, i.e. in the 2-class scenario's derived entity class.

How did this work in the v1.0.2005.1 version? I mean: also there you couldn't possibly be having the generated entity field property and your own code in the same class as you can't override a property in the same class of course.

Frans Bouma | Lead developer LLBLGen Pro
JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 20-Dec-2006 12:14:50   

I generated my code using SD.Presets.SelfServicing.General2005 instead of SD.Presets.SelfServicing.TwoClasses2005 - thanks for your help Otis, much appreciated.