Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
New child business objects parent key field not updated
Message
De
29/06/2004 09:54:17
 
 
À
25/06/2004 18:52:33
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00917438
Message ID:
00918430
Vues:
7
Hi Patrick,

I waited a couple of days to reply because I was looking forward to seeing a reply from someone who knows for sure what the problem is.

I also couldn't get child records to auto-populate foreign keys on Add of the parent table. I discovered if I set the Datarow property of the primary biz object to row 0 of the dataset then the foreign key would populate correctly.

Try adding the following line after GetCurrentDataSet.
(This is Vb.net syntex)
oCustomer.Datarow = dsCustomer.tables("Customer").Rows(0)

You need to also have a method to persist the datasets on postback. See the Developers Guide "Integrating Business Objects with a Web Form" for examples of persisting the dataset. Also note other methods to persist data "Persisting User State"

If you use a method to persist data, set the datarow property the same way after you retrieve the data from state.

Hope this works for you.

Terry Carroll





>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
>   ...
> }
>}
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform