This project is read-only.

Getting Root Element Of List containing dirty record

Jul 24, 2012 at 5:59 PM

Hi,

Is there a way to get hierarchical data from list? I have list containing list of objects. I want to know on which list is contains dirty record. So far GetErrorMessages method return all the dirty records in parent list.

For example, I have List<Person> containing List<Vendor>, List<Customer> and etc. When I provide engine.Validate(lstPerson) it returns error in it. When get GetErrorMessages return all the error messages which not able to identify on which vendor or customer it has error.

 

Hope you understood the scenario. 

Jul 24, 2012 at 11:17 PM
Edited Jul 24, 2012 at 11:19 PM

Hi,

Nope there is no way of doing that at the moment. You have 2 options:

1. Flatten your list, then iterate through them to find which object has errors on them.

            var lstToValidate = new List<object>();
            lstToValidate.AddRange(lstPersons);
            lstToValidate.AddRange(lstPersons.SelectMany(p => p.Vendors));
            lstToValidate.AddRange(lstPersons.SelectMany(p => p.Vendors).SelectMany(v => v.Customers));

            foreach (var o in lstToValidate)
            {
                var result = validationReport.HasError(o);
            }

2. Implement your own IValidationReport that wraps ValidationReport, and exposes all the Error records. (I might actually implement that on ValidationReport as a fix).

Of course, the million dollar question...what are you doing with all this validation? Presenting users with errors on a UI? Or reporting errors back to a consumer via WCF?

Jul 25, 2012 at 7:06 AM

Hi,

Please make that part of your component. It will help others too and won't let them to make mess of rule engine.

Firstly, Utilizing your component to validate business logic of my component. 

Secondly, currently preseting errors on UI. So that can see where it contains dirty records in it.

Finally, both options are good; error on UI and through WCF.

Jul 25, 2012 at 11:00 PM

Well, if you're using WPF to report errors on the UI, have a peek at http://polymod.codeplex.com/. It uses Aspect programming methods to wrap a business object and its rules (It also uses RulesEngine) into a Model. The Model implements IDataErrorInfo and your errors reported to the UI without you writing any code.

Jul 26, 2012 at 5:57 AM

Hi,

What is the purpose of Polymod .NET project? How it works? How can I valid in it? Any working example will be helpful in getting started.  

Jul 26, 2012 at 12:19 PM

Hello

It is basically a policy injection framework. There is a sample you can download from the home page.

Please post to the discussion board of polymod for future discussions.

Jul 26, 2012 at 12:24 PM

Hi,

I will post on related discussion board for the project. What about the change of IValidationReport? Are you going to provide that features?

Jul 26, 2012 at 12:24 PM

Hi,

I will post on related discussion board for the project. What about the change of IValidationReport? Are you going to provide that features?

Jul 26, 2012 at 12:44 PM

Yep, but won't be until next week I am afraid. Sorry.