Open Chicagoan2016 opened 7 years ago
My recommendation is to write synchronous rules.
The rule engine does not support async/await so it is much more cumbersome to wait for async rules to be completed.
Thank you @jonnybee
@jonnybee , since we are discussing business rules, I read somewhere on the forum( if memory serves) that the recommended approach is to use CSLA rules and avoid DataAnnotations, am I right?
Regards
Not quite - but you have more options on a CSLA Rule than with DataAnnotation (such as ShortCircuiting, Priority, OutValues and implicit Dependencies). For multi-lingual rules I also prefer CSLA rules over DataAnnotation.
DataAnnotation rules is wrapped with a lambda rule inside the RuleEngine (behind the scenes) and always Executed at Priority = 0. .
fwiw, DataAnnotation rules do support the use of resx files to get multi-lingual text, but I agree with Jonny that it is easier inside a CSLA rule.
The other drawback to DataAnnotations is that they are compiled into your code, so they are generally not useful for multi-tenant scenarios where the rules need to be loaded dynamically at runtime depending on the tenant.
Looks like .NET Core is getting closer to parity with DataAnnotations and localization as well.
https://andrewlock.net/localising-the-displayattribute-in-asp-net-core-1-1/
I have a web application (asp.net web forms), I am writing a business rule and I wonder if should make it asynchronous?
Regards