Question

I have a .NET object which is a collection, for example an Employee object containing list of employees.

I need to pass the same to the rules engine to do the looping inside the rule file.

Can you please help me with code to the same from .NET as well looping in xbre file. I have successfully passed an object with single record. However need to pass collection.

Was it helpful?

Solution

I suggest you pass the EmployeeWrapper object itself to NxBRE using the standard approach:

bre.RuleContext.SetObject("EmployeeWrapper", employeeWrapper);

then reflectively extract the list of employees with:

<ObjectLookup id="Employees" objectId="EmployeeWrapper" member="Employees" />

assuming the EmployeeWrapper object has a property named Employees which returns the collection of employees.

Then use a ForEach block to iterate the employees:

<ForEach id="Employee" valueId="Employees">
    ...
</ForEach>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top