//Create rule builder
var builder = new RuleModel.Builders.RuleBuilder();
builder.Name("TestRule");
//Customer pattern
PatternBuilder customerPattern = builder.LeftHandSide().Pattern(typeof (Customer), "customer");
Expression<Func<Customer, bool>> customerCondition =
customer => customer.Name == "John Do";
customerPattern.Condition(customerCondition);
//OR group
var orGroup = builder.LeftHandSide().Group(GroupType.Or);
//Order pattern 1
PatternBuilder orderPattern1 = orGroup.Pattern(typeof (Order), "order");
Expression<Func<Order, Customer, bool>> orderCondition11 =
(order, customer) => order.Customer == customer;
Expression<Func<Order, bool>> orderCondition12 =
order => order.Amount > 100.00m;
orderPattern1.Condition(orderCondition11);
orderPattern1.Condition(orderCondition12);
//Order pattern 2
PatternBuilder orderPattern2 = orGroup.Pattern(typeof (Order), "order");
Expression<Func<Order, Customer, bool>> orderCondition21 =
(order, customer) => order.Customer == customer;
Expression<Func<Order, bool>> orderCondition22 =
order => order.Amount < 10.00m;
orderPattern2.Condition(orderCondition21);
orderPattern2.Condition(orderCondition22);
//Build actions
Expression<Action<IContext, Customer, Order>> action =
(ctx, customer, order) => Console.WriteLine("Customer {0} has an order in amount of ${1}", customer.Name, order.Amount);
builder.RightHandSide().Action(action);