I was able to solve this by adding this line of code following the instantiation of the Comm object:
Comm oCommission = new Comm();
this.RegisterChildBizObj(oCommission);
I made a guess on this one when I saw that the Parent object was still not saved even though the PostSaveHook fires after the save. What perplexed me was that I had an exact same situation with another parent/child relationship just like this that did not require the registering of the child object.
Either way, this problem is solved.
>Hello all,
>
>I have just created a new entity in my business application which records a commission percentage assigned to a customer order to one or many salespersons. It is a simple 3 column table (plus an integer identity PK). In order to fill this table I have added a HookPostSave event for my order entity. When the order is saved (on an add of an order), I will go to another table to get the defaults for the customer and load the commision values from there for the order. The code for this is as follows:
>
>
>public void OrdrPostSave()
> {
> // If this is not an add of a ordr, do not further allocate (use the createdtm to determine this)
> if (Entity.OrdrDtm.AddSeconds(10) < DateTime.Now)
> return;
> // Allocate to salesperson
> CompRep oCompRep = new CompRep();
> oCompRep.GetCompRepsByCompID(Entity.CompID);
> Comm oCommission = new Comm();
> foreach (CompRepEntity CRE in oCompRep.EntityList)
> {
> // Insert to comm table
> CommDefaults CDEF = new CommDefaults(Entity.OrdrID, CRE.RepID);
> oCommission.NewEntity(CDEF);
> oCommission.Entity.CommPct = CRE.CommRepPct;
> oCommission.SaveEntity();
> }
> }
>
>
>However, when I run this I get a SQL timeout error on the SaveEntity line. Now, I tested running the save of the commission record by itself in a test bench and it works fine that way, but it doesn't when it is run as the post save event of the order, Please note that I am running the above method from the HookPostSaveEntity event of the Order object.
>
>Any ideas as to why this is happening? And, if not, how can I determine in SQL, what might be the problem with the timeout. I can't seem to get any further information from SQL other than that the timeout has occurred.
>
>TIA
>
>Bob