Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where do I put code to do this
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01083295
Message ID:
01084120
Views:
9
Hi Kevin,

>When you call a business object method that fills "Order", then e.TableName will be "Order". When you call a business object method that fills the OrderAnyAll table, then e.TableName will be "OrderAnyAll". Are you specifically calling a business object method to fill the OrderAnyAll table?
>

I should give a little more information about what I'm doing (isnt that always the case *g*).

Order and OrderAnyAll are not derived directly from a database. They are built on the fly by reading portions of its parent bizobj field that contains xml. I read this field in the retrieve/add/etc hook method of the child, parse a particular node from the xml, fill a dataset with the information, and then set the current dataset of the childbizobj to the dataset.

Then I treat it like a normal bizobj until saving, I use the PreSaving hook to update the parent bizobj's xml field if the "fake" Orders bizobj IsChanged.

Here's a paired-down example:
public class boFakeOrder:boFakeBizobj
{
    public boFakeOrder()
    {
        this.XMLPath="Criteria/Orders";
    }
}


public class boFakeBizobj:ABusinessObject
{
  public string XMLPath=""; // path to node within XML that holds data for this bizobj 
...
  protected override void HookParentRetrieved(mmBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
  {
     string sXML = "";

     // when a row is added to the parent, retrieved is called but
     // no records will be in the parent bizobj, so there is no Rows in the
     // collection, so check if there are rows first

     if(bizObj.GetRowCount()>0)
     {
        sXML=bizObj.GetCurrentDataSet().Tables[0].Rows[0]["cSearchCriteria"].ToString();
        this.PopulateFromXML(sXML,bizObj);
     }
  }

  protected virtual void PopulateFromXML(string sXML,mmBusinessObject bizObj)
  {
     DataSet oDS = this.CreateDataSet();
     this.FillFromCriteriaXML(oDS,sXML,bizObj);
     this.SetCurrentDataSet(oDS);
     oDS.AcceptChanges(); // This will prevent dataset from being automatically seen as "changed"
  }

  protected override void HookParentPreSaving(mmBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
  {
     // This hook fires before business rules are applied 
     // and before save is performed.
			
     // If the fake bizobj has changed, then the parent's xml 
     // needs to be updated.
			
     if(this.IsChanged())
        this.UpdateParentXML(bizObj);
   }

}
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
www.RickHodder.com
MyBlog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform