Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RowState is unchanged on consecutive adds for a BO
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01297505
Message ID:
01297572
Views:
20
Further analysis in this shows that when the offset rule is run the second time there are 2 records in the dataset that is passed to the business rule. Since the first record in the dataset is the first record added successfully, and is current when the rule fires, it does not think anything has changed and therefore the validate methods do not run, which is not what I want

How do I change this so that the business rule is enforced on the second (or subsequent) record additions?

Thanks in advance.
>All,
>
>I have created a business process that uses two business objects. Essentially, I am adding a single record into the first business object (profit), getting its Primary key and then add two (or more) records in the second business object (offset) that contains the PK from the first as a foreign key.
>
>Here is the code for adding the two child rows:
>
>
>
>            // Now add the offset records
>            hasBrokenRules = this.CreateOffsetRecord(tradeID1, profitID, quantity);
>            if (hasBrokenRules)
>            {
>                this.oProfit.GetProfitByProfitID(profitID);
>                this.oProfit.Delete();
>                return mmSaveDataResult.RulesBroken;
>            }
>            hasBrokenRules = this.CreateOffsetRecord(tradeID2, profitID, quantity);
>            if (hasBrokenRules)
>            {
>                this.oProfit.GetProfitByProfitID(profitID);
>                this.oProfit.Delete();
>                return mmSaveDataResult.RulesBroken;
>            }
>
>
>If rules are broken, I am just deleting the profit record. Now, heres the problem. When I run createoffsetrecord the second time, the checkruleshook method in the Rules class for the offset object does not run because the RowChanged state is "Unchanged".
>
>Here is the createoffsetrecord method:
>
>private bool CreateOffsetRecord(int tradeID, int profitID, int quantity)
>        {
>            OffsetDefaults OD = new OffsetDefaults(profitID, tradeID);
>            this.oOffset.NewEntity(OD);
>            this.oOffset.Entity.offsetqty = quantity;
>            this.oOffset.SaveEntity();
>            return this.oOffset.Rules.HasBrokenRules;
>        }
>
>
>The second record I am adding has a different tradeID, so my question is why is the RowState unchanged on the second add row operation? Am I missing some command here?
>
>Any help is appreciated.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform