Replies: 2 comments 8 replies
-
@ruwentos first regarding the "conflict" resolution. The conflict occurs if multiple rules are able to fire at the same time. The engine has to choose one, and that is what's called conflict resolution. In your case there is no conflict. I hope this helps, please lmk if anything is unclear. |
Beta Was this translation helpful? Give feedback.
-
@ruwentos it's a bit hard for me to figure out from this code what exactly is the desired behavior, but simply looking at it mechanically, it seems the implementation of public bool IsNameMatched(Entry entry, BankAccount bankAccount)
{
return _nameMatches.TryGetValue(entry.Id, out var entryBankAccount) && entryBankAccount.Id == bankAccount.Id;
} But I'm totally with @a046 regarding these elaborate internal data structures that you created, to keep track of which rules fired. Seems overly complex, potentially misusing the engine. public class SearchResult
{
public BankAccount BankAccount { get; }
public SearchResult(BankAccount bankAccount)
{
BankAccount = bankAccount;
}
}
public class FindAccountsWithMatchingNamesRule : Rule
{
public override void Define()
{
BankAccount bankAccount = default;
Entry entry = default;
When()
.Match(() => entry)
.Query(() => bankAccount, q => q
.Match<BankAccount>(
ba => ba.Iban == entry.Iban)
.Collect()
.Where(c => c.Count() > 1)
.Select(c => c.First(x => entry.RelatedPartyAccount.Contains(x.Name)))
);
Then()
.Yield(x => new SearchResult(bankAccount));
}
} Then in the test code after calling var fired = session.Fire();
var results = session.Query<SearchResult>().ToArray(); I hope this helps |
Beta Was this translation helpful? Give feedback.
-
I try to figure out what is expected behavior from the engine. The explanation says this:
What 'conflict' does it mean here?
In my case I have two rules.
Rule 1 can fire immediately. Rule 2 cannot fire after init.
Rule 1 changes a fact. This change would make Rule 2 fire. It does not.
I then put .Do(ctx => ctx.Update(fact)) to the action of Rule 1. This makes Rule 2 fire.
Question: I expect from the above text that the engine notices a change of a fact and activates all rules again. I never read about an explicit 'Update'. How does it work correct?
Beta Was this translation helpful? Give feedback.
All reactions