Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm trying to filter a DynamicNodeList on more than one field, but failing misserably. Is it possible to do in one .Where clause? This is what I've come up with so far:
items = root.Descendants("alias"); var values = new Dictionary<string,object>();values.Add("fromA", 0); values.Add("toA", 100); values.Add("fromB", 0); values.Add("toB", 100); string s=""; s = "(priceA >= fromA && priceA <= toA) || (priceB >= fromB && priceB <= toB)";DynamicNodeList possibleNodes = items.Where(s, values);
A solution would be to seperate the conditions and join the results from the 2 Where filters, ut as far as I know, you can't join DynamicNodeLists.
Any help appreciated.
Solved it like this (saved for reference)
List<DynamicNode> nl = items.Items; var possibleNodes = nl.Where(x => x.GetProperty<int>("fromA") >= int.Parse(Request["priceA"]) && x.GetProperty<int>("fromB") <= int.Parse(Request["priceA"]) || x.GetProperty<int>("fromB") >= int.Parse(Request["priceB"]) && x.GetProperty<int>("fromB") <= int.Parse(Request["priceB"]));
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
DynamicNodeList .Where() on more than one field
Hi,
I'm trying to filter a DynamicNodeList on more than one field, but failing misserably. Is it possible to do in one .Where clause? This is what I've come up with so far:
A solution would be to seperate the conditions and join the results from the 2 Where filters, ut as far as I know, you can't join DynamicNodeLists.
Any help appreciated.
Solved it like this (saved for reference)
is working on a reply...