This project is read-only.

Filter ContentItems based on ContentFields

Topics: Customizing Orchard
Apr 14, 2011 at 7:29 AM



I'm struggling with filtering using the ContentManager. As I'm looking through the BlogService I see that you can join ContentParts and have filtering applied.


However, what happens if I want to filter on a ContentField? 

I have yet to find any docs on the subject, and the extension methods I see for the content manager do not include this case.

How do I filter ContentItems based on a ContentField?

Apr 14, 2011 at 8:58 PM

You can't. If you need filtering, don't use a field.

Apr 15, 2011 at 6:10 AM


I was expecting your answer to be no. I would like to add a bit to this for future reference with the other members of the community.

The reason I cannot filter on content fields is that behind the scenes, when you add a Content Field to a content type. That field along with any other field(s) you have defined are stored in a table as XML.

Since you cannot join on XML fields/values you cannot filter also.

It would probably be best to consider Content Fields as additional metadata.

As Bertrand pointed out, if filtering is what we're after, we should define content parts, and use the ContentManager for querying and filtering on the content part for a specific content type.


I want to thank you for the quick reply. Orchard is awesome in so many ways. The Orchard Team ROCKs!!!