Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nested lambda expressions in rule conditions #1

Open
jonechenug opened this issue May 7, 2018 · 2 comments
Open

Add support for nested lambda expressions in rule conditions #1

jonechenug opened this issue May 7, 2018 · 2 comments

Comments

@jonechenug
Copy link

I had use NRules.Language some little time . It is powerful !
But now I have a problem when using nested objects .Think you have a "Order" object , it has a list to store the detail item. Now I have a rule that when any item has some product , the order will had a discount .
The rule look like

Name "order rule smaple"
when
   var order= Order(x=>x.Items.Any(i=>i.Product.Name=="some product")); 
then 
    order.discount=1;

Unfortunately,it is not work.The erro message say " x.Items has not a member "Any" " . When I debuging,the Items only has its' index member. So the rule only support look like "x.Items[index].Product.Name=="some product"" .

@jonechenug jonechenug changed the title How to write a rule for nested objects when i using lambda? How to write a rule for nested objects when I use lambda? May 7, 2018
@snikolayev
Copy link
Member

You are right, nested lambdas are not yet supported. So this is a valid feature request. It's going to take a little while to add this feature, so meanwhile you can have a workaround - encapsulate the lambda expression behind an extension method on the Order object.

@snikolayev snikolayev changed the title How to write a rule for nested objects when I use lambda? Add support for nested lambda expressions in rule conditions May 7, 2018
@harsh-chaturvedi
Copy link

@snikolayev Any updates on this? Support for nested lambda and execution of linq queries would be really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants