Closed jperezmedina closed 5 years ago
Do you have the ability to alter the Base Class? Currently the MicroRuleEngine can execute a boolean method given an array of inputs, and there are a couple examples of that.
I'm new with C#. Could you detail more about it? How alter the base Class to support collection[0].feature? Where are the examples? Thanks On Nov 7, 2015 12:56 AM, "runxc1(Bret Ferrier)" notifications@github.com wrote:
Do you have the ability to alter the Base Class? Currently the MicroRuleEngine can execute a boolean method given an array of inputs, and there are a couple examples of that.
— Reply to this email directly or view it on GitHub https://github.com/runxc1/MicroRuleEngine/issues/5#issuecomment-154580765 .
I've added this feature to my fork (https://github.com/jamescurran/MicroRuleEngine). Using the new syntax, it would be:
Rule rule = Rule.Create("Items[0].Cost", mreOperator.LessThanOrEqual, 8.10m);
@jamescurran , would you also be able to use the linq method All / Any on a collection?
somthing like Rule rule = Rule.Create("Items[].Status", mreOperator.All, "Shipped");
So, basically, you'd want it to be the equivalent of "Items.All(i=>i.Status == Shipped)" ?
Actually, this should work for that (I'd forgotten about it)
Rule rule = Rule.All("Items", Rule.Create("Status", mreOperator.Equal, "Shipped"));
The changes from @jamescurran enabling this have been pulled in so this is now possible.
I rule example of how to use the MicroRuleEngine with a childProperty is included in the solution. For instance:
But, in my case, I need create a rule that evaluates is the cost of the Item with the ItemCode = "MM23" (so, the first Item object) is 'LessThanOrEqual' to 8.10M. How i can make it ?