Click here to Skip to main content
16,018,534 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Suppose I have a rule
Rule1: Age is greater that 18
Rule2 : firstname starts with a
Now I am trying to create a rule 3: if rule 1 is true and rule 2 is true.

When I am trying to filter the result by the following code
C#
IEnumerable<MemberCls> lst = objMemberCls.GetMemberList().Filter(rule);

It raises an exception as follows "Rule with id 'xxx' not found"

Below one is the entire code
C#
public ActionResult Evaluate(MemberCls patient, RuleModel ruleEditor)
        {

            ruleEditor.BindSource(typeof(MemberCls));

            ruleEditor.SkipNameValidation = true;
            ViewBag.Rule = ruleEditor;

            if (ruleEditor.IsEmpty() || !ruleEditor.IsValid(StorageService.LoadRuleXml))
            {
                ViewBag.Message = "The rule is empty or invalid";
                return View("Index");
            }

            string rule = ruleEditor.GetRuleXml();

            Evaluator<membercls> evaluator = new Evaluator<membercls>(rule, StorageService.LoadRuleXml);
            bool success = true;

            Patient objPatient = new Patient();
            MemberCls objMemberCls = new MemberCls();
            if (success)
            {
                IEnumerable<membercls> lst = objMemberCls.GetMemberList().Filter(rule);
                objPatient.lstMember = lst.ToList();
            }

            ViewBag.Rule = RuleModel.Create(typeof(Patient));


            if (!string.IsNullOrWhiteSpace(patient.Output))
                ViewBag.Message = patient.Output;
            else
                ViewBag.Message = "The current rule evaluated to " + success;

            return View("Index", objPatient);
        }


Can I know How to resolve this issue?
Posted
Updated 14-Jan-14 1:16am
v6
Comments
Kornfeld Eliyahu Peter 14-Jan-14 6:15am    
We need more code.
Let us see how the filters are handled inside MemberCls...
And also show the filter declaration part...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900