var matchedProperty = dbfieldList.Where(w => w.ObjectType == f.ObjectType && w.RuleId == f.RuleId && w.PropertyName == f.PropertyName).ToList();
if (matchedProperty != null && matchedProperty.Count > 1)
{
//there are multiple conditions for this property so "OR" them
var orGroup = builder.LeftHandSide().Group(GroupType.Or);
PatternBuilder orPattern = orGroup.Pattern(f.ObjectType, f.ObjectType.Name.ToLower());
foreach (var mp in matchedProperty)
{
//where SetCondition builds a lambda expression & returns it
orPattern.Condition(SetCondition(mp, ExpressionMode.TargetValue));
}
action = (ctx) => ProcessAssessmentFieldResult(ctx);
builder.RightHandSide().Action(action);
ruleList.Add(builder.Build());
continue;
}
var matchedProperty = dbfieldList.Where(w => w.ObjectType == f.ObjectType && w.RuleId == f.RuleId && w.PropertyName == f.PropertyName).ToList();
if (matchedProperty != null && matchedProperty.Count > 1)
{
//there are multiple conditions for this property so "OR" them
var orGroup = builder.LeftHandSide().Group(GroupType.Or);
foreach (var mp in matchedProperty)
{
builder.Property("AssessmentField" + "-" + mp.AssessmentFieldId, mp); //store field definition
//where SetCondition builds a lambda expression & returns it
PatternBuilder orPattern = orGroup.Pattern(f.ObjectType, f.ObjectType.Name.ToLower());
orPattern.Condition(SetCondition(mp, ExpressionMode.TargetValue));
}
//on completion add to the processedMatchedProperty list to prevent it being processed again
processedMatchedProperties.AddRange(matchedProperty);
action =
(ctx) => ProcessAssessmentFieldResult(ctx);
builder.RightHandSide().Action(action);
ruleList.Add(builder.Build());
}