I think that this is because when you pass the string parameter to a .Where method it uses a dynamic expression parser and the fixed properties that are supported to not include DocumentTypeId (i'm 100% clear on this though). Anyway, you can do what you need with the lambda expression:
DocumentTypeId in Where not working?
Hello
I am trying to get a set of nodes based on thier DocumentTypeId (from at Macro contentTypeMultiple list). But the following code do not work:
nodes = root.DescendantsOrSelf().Where("DocumentTypeId == 1000");but
works?
The reason why i am not using the last one is that i want to generate a flexible query, which can contain multiple DocumentTypeIds with OR. Ex:
nodes = root.DescendantsOrSelf().Where("DocumentTypeId == 1000 || DocumentTypeId == 1001");Is there any reason that the first Where query dont work and the second does?
Hi,
I think that this is because when you pass the string parameter to a .Where method it uses a dynamic expression parser and the fixed properties that are supported to not include DocumentTypeId (i'm 100% clear on this though). Anyway, you can do what you need with the lambda expression:
Thanks,
Jeavon
I wonder if Contains would work too here? You could eliminate need for any string generation. For example: (warning not tested!)
int[] ids = new int[] { 1000, 1001, 1002, 1003 }; // or any IEnumerable<int>var nodes = root.DescendantsOrSelf().Where(x => ids.Contains(x.DocumentTypeId));
Good luck!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.