This project has moved. For the latest updates, please go here.

Adding Value Properties to a Derived Class

Developer
May 17, 2013 at 2:50 PM
I've defined a base Order class (OrderBase) from which I'm deriving Invoice and PO. I'm attempting to add a value property (FreightCost) to the Invoice in CslaGenFork but receiving a compiler error in the 'PropertyInfo' declaration in the generated file.
        public static readonly PropertyInfo<Decimal?> FreightCostProperty = RegisterProperty<Decimal?>(p => p.FreightCost, "Freight Cost", null);
Compiler error
'StandardInvoice.Data.ER.Base.OrderBase' does not contain a definition for 'FreightCost' and no extension method 'FreightCost' accepting a first argument of type 'StandardInvoice.Data.ER.Base.OrderBase' could be found (are you missing a using directive or an assembly reference?) C:\Users\WKR0226\Documents\Visual Studio 2010\Projects\StandardInvoice\Main\StandardInvoice.Data\ER\InvoiceTest.designer.cs 24  111 StandardInvoice.Data
Coordinator
May 19, 2013 at 11:39 AM
Hi Keith,

As far as I can see this isn't a cslaGenFork issue. There something wrong with your code. If the problem is wrong CslaGenFork generated code, that could be a CslaGenFork issue.
Developer
May 20, 2013 at 1:16 AM
Edited May 21, 2013 at 12:54 AM
tiago wrote:
Hi Keith,

As far as I can see this isn't a cslaGenFork issue. There something wrong with your code. If the problem is wrong CslaGenFork generated code, that could be a CslaGenFork issue.
<br/>
The code is all generated by CslaGenFork. The value properties in the base class are defined as managed without a defined 'DB Bind Column' value. All the 00.Generate Options in the base class are set to false except 'Generate Object'. The derived class has the 'Inherited Type' in 01. Common Options is set to the base class with one additional value property and the generated code produces the compiled error mentioned.
Developer
May 21, 2013 at 1:37 AM
tiago wrote:
Hi Keith,

As far as I can see this isn't a cslaGenFork issue. There something wrong with your code. If the problem is wrong CslaGenFork generated code, that could be a CslaGenFork issue.
<br/>
You are correct. The problem was I had not properly declared the base class. The real problem is my lack of understanding of generics. I was trying to define the base class as
    public abstract class OrderBase : BusinessBase<OrderBase>
When it needed to be:
    public abstract class OrderBase<T> : BusinessBase<T> where T : OrderBase<T>
Is it better to define the properties in the base class or define as an Interface and implement in each derived class? There will be roughly 20 properties shared across 4 derived classes (Invoice, PO, Quote, SO) and each derived class will have a few properties unique to themselves.