Properties passed into Business Rule Constructor seem to automatically be Dependent/Affected Properties #3415
Unanswered
mtavares628
asked this question in
Questions
Replies: 2 comments 9 replies
-
I know CommonBusinessRule, which inherites from PropertyRule, has 'CanRunAsAffectedProperty' |
Beta Was this translation helpful? Give feedback.
0 replies
-
Using this run code: using Csla;
using Csla.Configuration;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddCsla();
var provider = services.BuildServiceProvider();
var dp = provider.GetRequiredService<IDataPortal<Root>>();
var root = await dp.FetchAsync();
root.ID = 123;
root.ReferenceDate = DateTime.Today.ToString(); I'm seeing the Twice due to the It doesn't get triggered when the reference date is set. Why |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've noticed this issue which ends up causing the same rules on my object to be run over and over. Basically if I pass properties (besides the PrimaryProperty) to the constructor of my rule (Rule A), and that passed in property is used as a PrimaryProperty in some other rule (Rule B), then Rule A gets called again whenever Rule B has been called. I would expect this to happen if I added the property to the AffectedProperties list for the rule, or added a Dependency rule between the 2 properties, but I'm not doing that.
Here is a sample that recreates the behavior. If you set a breakpoint on ExecuteAsync of the IDRule below, then it will get called twice when CheckRules is called.
Is this by design? And if so, then how can I create rules with multiple properties, and prevent the rule from being called multiple times if the secondary (non-PrimaryProperty) has it's own set of rules? I can't use the Target object either, since my rules need to be Async for Blazor.
Beta Was this translation helpful? Give feedback.
All reactions