Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Constructor Hooks
Message
From
05/05/2007 20:04:34
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Constructor Hooks
Miscellaneous
Thread ID:
01222803
Message ID:
01222803
Views:
58
Hi!

Just wondering what the correct approach would be in creating a Pre/Post Constructor Hook for BO's?

Problem:
All the code that I add to the BO's constructor is overwritten everytime I run/re-run the BLG.

e.g.
public OrderDetail()
{
   // Code generated by the BLG (in the OrderDetail.cs file)
   this.TableName = "OrderDetails";
   this.PhysicalDbcObjectName = "Order Details";
   this.PrimaryKeys = new string[] {"OrderID", "ProductID"};
   
   // Code that I add later (also in the OrderDetail.cs file)
   // This can be different based on the BO
   // The code below is overwritten everytime I run/rerun the BLG.
   this.AutoSaveOnParentSaved = true;
   this.AutoCancelOnParentCancel = true;
   this.AutoDeleteOnParentDeleted = true;
   this.AutoEmptyOnParentAdded = true;
   this.ForeignParentKeyField = "OrderID";
}
If there is an overriden/overloaded PreConstructor() or PostConstructor() Hook avaiable then I could write my code in it and not loose my changes.
Similar to the
protected override void HookParentNavigated(mmBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
or
protected override void HookParentRetrieved(mmBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
e.g.
protected override void HookPostConstructor()
{
   // Code that I add later (in the OrderDetail.Partial.cs file)
   // This can be different based on the BO
   // This is now safe as the BLG will not overwrite this
   // as it is in a different physical file (OrderDetail.Partial.cs )
   this.AutoSaveOnParentSaved = true;
   this.AutoCancelOnParentCancel = true;
   this.AutoDeleteOnParentDeleted = true;
   this.AutoEmptyOnParentAdded = true;
   this.ForeignParentKeyField = "OrderID";
}
Sarosh
Next
Reply
Map
View

Click here to load this message in the networking platform