Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
New child business objects parent key field not updated
Message
De
25/06/2004 18:52:33
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
New child business objects parent key field not updated
Divers
Thread ID:
00917438
Message ID:
00917438
Vues:
44
I have a page that the user creates a customer, order, and orderlines at the same time.
(leaving out orderlines for clarity)

When I save (insert) a NEW parent object:
mmSaveDataResult result = this.Save( oCustomer );
child business object tables get saved, but foreign keys DO NOT get populated with the Parent foreign key value.

I traced through MM code, and it seems Parent foreign keys ONLY get saved in child objects if the value already exists before the save. (I could be wrong about this.)

Maybe I'm doing something wrong, please avise.

Thanks!

Business object settings follow:
Business.cs
public ABusinessObject()
{ ...
 this.RetrieveAutoIncrementPK = true;
 this.AutoSaveOnParentSaved = true;
}

public CustomerBusiness()
{
 this.TableName = "Customers";
 this.PrimaryKey = "CustomerID";
 this.ClearOnFillDataSet = true;
 this.AutoUseTransactions = true;
}
public OrderBusiness()
{
this.TableName = "Orders";
this.PrimaryKey = "OrderID";
this.ForeignParentKeyField = "CustomerID";
}
page
 // declare BusinessObjects
 ...
private void Page_Load(object sender, System.EventArgs e)
{
 // instantiate the business objects and register with the form
 ...
 // create business object hierarchy
 oCustomer.RegisterChildBizObj(oOrder);
 ...
 
 if (! IsPostBack)
 {
   if (Request.QueryString["id"] == String.Empty)
   {
     oCustomer.GetEmptyDataSet();
     oCustomer.NewRow();
     dsCustomer oCustomer.GetCurrentDataSet();

     oOrder.GetEmptyDataSet();
     oOrder.NewRow();
     dsOrder oOrder.GetCurrentDataSet();
   }
   else 
     // get data from db
   ...
 }
}
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform