How can I filter on content types? I am able to filter on values of custom properties, but cannot filter on content types.
This works: var accordeonGroups = DynamicModel.Children.Where("isAccordeonGroup == true"); This does not: var accordeonGroups = DynamicModel.Children.Where("ContentType.Alias == \"accordeonGroup\"");
I now use the first method, for which I first add a custom property 'isAccordeonGroup' to the content type and set it to true manually for every node of the type. This works fine, but is cumbersome and error-prone.
Is there another way to write the second where clause?
Umbraco 5 filter on ContentType in where clause
How can I filter on content types? I am able to filter on values of custom properties, but cannot filter on content types.
This works: var accordeonGroups = DynamicModel.Children.Where("isAccordeonGroup == true");
This does not: var accordeonGroups = DynamicModel.Children.Where("ContentType.Alias == \"accordeonGroup\"");
I now use the first method, for which I first add a custom property 'isAccordeonGroup' to the content type and set it to true manually for every node of the type. This works fine, but is cumbersome and error-prone.
Is there another way to write the second where clause?
I'm not sure about DynamicModel as it is of type BendyObject.
But for Model (of type Content) you do this:
var nodes = Model.Children.Where(x => x.ContentType.Alias == "MyDocTypeAlias")
Perhaps you could try
DynamicModel.Children.Where("Alias == \"accordeonGroup\"");
or
DynamicModel.Children.Where("NodeTypeAlias == \"accordeonGroup\"");
Ah nice, that solves my issue :).
Thanks, I did not yet know Model would get me a lot more than just DynamicModel.
Persoanlly I dont like DynamicModel. I develop in VS and like the intellisense that Model gives.
is working on a reply...