I want to create a rule in rule builder, the rule which I want to create uses query method. How to create the same type of rule in Rule-Builder?
I want to achieve this using rule-builder. How can I create this type of rule dynamically in rule-builder?
public class LargeTotalRule : Rule
{
public override void Define()
{
Customer customer = null;
IEnumerable orders = null;
double total = 0;
When()
.Match<Customer>(() => customer, c => c.IsPreferred)
.Query(() => orders, x => x
.Match<Order>(
o => o.Customer == customer,
o => o.IsOpen)
.Collect())
.Let(() => total, () => orders.Sum(x => x.Amount))
.Having(() => total > 100);
Then()
.Do(ctx => Console.WriteLine("Customer {0} has orders over $100 total", customer.Name));
}
}