support for EditableChildList in template

Aug 18, 2011 at 3:32 PM

Josip, I might have missed something, but the following code fails at two points:           

PurchaseOrder order = PurchaseOrder.New();
//modify properties
order = order.Save();

PurchaseOrderLine line = order.PurchaseOrderLines.AddNew(); // exception 1
//modify properties
order = order.Save(); // exception 2

In exception 1, PurchaseOrderLines is empty, shouldn't this be changed in the template to generate:

public static PropertyInfo<PurchaseOrderLineList> PurchaseOrderLinesProperty = RegisterProperty<PurchaseOrderLineList>(c => c.PurchaseOrderLines);
public PurchaseOrderLineList PurchaseOrderLines
{
	get {
        if (!(FieldManager.FieldExists(PurchaseOrderLinesProperty)))
            LoadProperty(PurchaseOrderLinesProperty, DataPortal.CreateChild<PurchaseOrderLineList>()); 
                
        return GetProperty<PurchaseOrderLineList>(PurchaseOrderLinesProperty);
    }
	private set 
	{
		SetProperty<PurchaseOrderLineList>(PurchaseOrderLinesProperty, value);			
	}
}

The second exeption is a referential integrity violation which is, i think, related to this thread: the parentID is not set in the child object. Instead of diving into the template, are these issues fixed already perhaps?

Coordinator
Aug 19, 2011 at 7:26 AM

You need to take care of child objects manually. I do this by implementing partial methods in a partial class of base object. 

Eg:

    public partial class PurchaseOrder
    {
        partial void AfterCreate()
        {
            this.PurchaseOrderLines = PurchaseOrderLines.New();
        }
    }