Click or drag to resize

IRuleApiEvalT Method (String, String, RuleParameter)

Evaluate a rule with parameters.

Namespace:  Casewhere.Runtime.DSL.Api
Assembly:  Casewhere.Runtime (in Casewhere.Runtime.dll) Version: 2.8.1.0
Syntax
C#
T Eval<T>(
	string ruleCacheKey,
	string ruleExpression,
	params RuleParameter[] parameters
)

Parameters

ruleCacheKey
Type: SystemString
Name of the rule.
ruleExpression
Type: SystemString
Rule code expression.
parameters
Type: Casewhere.Runtime.DSLRuleParameter
Array of RuleParameters needs to evaluate expression.

Type Parameters

T
Return value type

Return Value

Type: T
Value return from rule expression
Examples
var ruleApi = ctx.Use<IRuleApi>();
var dataApi = ctx.Use<IDataApi>();
var employee = dataApi.Load("CwUatEmployee/c83fe344-3ee6-4951-90e7-adfe006584ba");
var query = DataObjectApiQuery.For("CwUatEmployee").FilterBy(FilterBuilder.Create().Build());
query.Take = 10;
var queryResult = dataApi.Search(query);
var ruleParameters = new List<RuleParameter>()
{
    new DataObjectRuleParameter("dataObj", employee),
    new ScalarRuleParameter("number", " 12"),
    new DataObjectListRuleParameter("dataObjList", queryResult.Data)
};
var result = ruleApi.Eval<string>(
    "DynamicRuleKey", 
    @"#predicate
         var obj1Names = dataObjList.Where(w => w.JobTitle == ""Recruiter"").Select(s => s.Name);    
         return dataObj.Name + number + "" names: "" + string.Join("","", obj1Names) ;  ", 
    ruleParameters.ToArray()
);
See Also