Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Constructor Hooks
Message
De
05/05/2007 20:04:34
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Constructor Hooks
Divers
Thread ID:
01222803
Message ID:
01222803
Vues:
54
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform