Calling methods and List support in rul file

48 views
Skip to first unread message

srikanth srivastav

unread,
Aug 14, 2019, 3:15:07 AM8/14/19
to NRules Users
using rulesengine;
using System;
using System.Collections.Generic;
using System.Linq;

rule "Order Discount"
when
    var customer = Customer(x => x.IsPreferred);
    var order = Order(x => !x.IsDiscounted, x => x.Quantity > 10);
    
then
    order.PercentDiscount = 5.0;
    customer.RuleComment= "some comment";
    customer.Comments.Add("some changes");
    Context.Insert(customer.Comments);
    Load("some string");

public static void Load(string str)
{
    
}

Hi Sergiy,
         Above is me rul file, Wanted to know if calling method inside the rul file is allowed/suported (tried non static method as well) and also wanted to know if List namespace is allowed. 

Sergiy Nikolayev

unread,
Sep 17, 2019, 8:04:18 PM9/17/19
to NRules Users
I know it's been a while, but in case you are still interested - no, defining methods within rules files is not allowed. You can only call methods on the types imported from other .NET assemblies, or call methods methods on facts you matched.
Reply all
Reply to author
Forward
0 new messages