Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Business Process
Message
From
23/02/2011 07:01:32
 
 
To
22/02/2011 18:04:38
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01501252
Message ID:
01501395
Views:
33
Hi Tim,

yes, those are returning true (got bitten by that some months back).

The problem I am having is the DataSets of the child objects are empty during the save!

My code does this:
                oPolicyLoan = new PolicyLoan();
                oPolicyLoan.GetEmptyDataSet();
                oPolicyLoan.NewEntity();
                oPolicyLoan.Entity.PolicyHeaderFK = oPolicyHeader.Entity.PolicyHeaderPK;
                oPolicyLoan.Entity.LoanDate = DateTime.Now;
                oPolicyLoan.Entity.LoanAmount = (Decimal)oPolicy.Entity.Premium;
                oPolicyLoan.Entity.LoanType = "APL";
                oPolicyLoan.Entity.UserFK = userPK;
then this:
mmSaveDataResult result = this.oPolicyHeader.SaveEntity();
oPolicyLoan is registered as a child of oPolicyHeader.

At the point in time when the SaveEntity is called, oPolicyLoan.DataSet has the data that I expect in it. As soon as I step into the SaveEntity code, oPolicyLoan.DataSet becomes disabled in the Watch window. Does that mean it is going out of scope? The parent is saving OK.

>make sure if you are using Hook Pre save methods that you are returning true for the save to complete.
>tim
>
>>Thanks.
>>
>>I'm now having difficulty saving :(
>>
>>I am setting a value like this:
>>
>>oPolicyHeader.Entity.PremiumLate = some value
>>
>>then later on doing this:
>>
>>mmSaveDataResult result = this.oPolicyHeader.SaveEntity();
>>
>>which shows that the rules passed, but the value that was in the entity has not been saved to the table. If I look at the oPolicyHeader.DataSet, the corresponding field is blank. What causes the Entity values to be sent back to the DataSet or at least to be saved to the underlying table?
>>
>>
>>>There is a HookPreSaveEntity method as well which I guess gets called before SaveEntity. I would create another method to do what you want in a preSave and then call that method from both HookPreSave and HookPreSaveEntity.
>>>
>>>
>>>>Thanks again.
>>>>
>>>>I did find a difference between SaveEntity() and SaveDataSet(). I have some code in an BO's HookPreSave which does not get called when I call SaveEntity(). Should it, or should I put my HookPreSave code somewhere else?
>>>>
>>>>>Frank,
>>>>>
>>>>>That seems about right. Make sure you also add to the child business objects the following in the HookConstructor method:
>>>>>
>>>>>
>>>>>protected override void HookConstructor()
>>>>>		{
>>>>>            this.AutoSaveOnParentSaved = true;
>>>>>            this.AutoCancelOnParentCancel = true;
>>>>>            this.AutoDeleteOnParentDeleted = true;
>>>>>            this.AutoEmptyOnParentAdded = true;
>>>>>            this.ForeignParentKeyField = "insert FK here";
>>>>>		}
>>>>>
>>>>>
>>>>>The only time the above code is used is when you use the RegisterChildBizObj method.
>>>>>
>>>>>Don't know the difference between SaveEntity and SaveDataSet as I always use SaveEntity.
>>>>>
>>>>>Bob
>>>>>
>>>>>>Thanks Bob,
>>>>>>
>>>>>>so my code should look like this?
>>>>>>
>>>>>>
        protected override void DefineParticipatingObjects()
>>>>>>        {
>>>>>>            this.oPolicyHeader = (PolicyHeader)this.RegisterBizObj(new PolicyHeader());
>>>>>>            this.oPolicy = (Policy)this.RegisterBizObj(new Policy());
>>>>>>            this.oPolicyLoan = (PolicyLoan)this.RegisterBizObj(new PolicyLoan());
>>>>>>            this.oReceipt = (Receipt)this.RegisterBizObj(new Receipt());
>>>>>>            this.oReceiptDetail = (ReceiptDetail)this.RegisterBizObj(new ReceiptDetail());
>>>>>>
>>>>>>            this.oPolicyHeader.RegisterChildBizObj(this.oPolicy);
>>>>>>            this.oPolicyHeader.RegisterChildBizObj(this.oPolicyLoan);
>>>>>>            this.oPolicyHeader.RegisterChildBizObj(this.oReceipt);
>>>>>>            this.oReceipt.RegisterChildBizObj(this.oReceiptDetail);
>>>>>>        }
>>>>>>
>>>>>>Then when I want to save I just do:
>>>>>>
>>>>>>
mmSaveDataResult result = oPolicyHeader.SaveEntity();
>>>>>>
>>>>>>How do I decide if I want to call SaveDataSet or SaveEntity or something else?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform