Query ContentPart by field in Orchard CMS

I work in Orchard 1.4, where I have a piece of content ProductPartthat has a boolean field IsFeatured. It is easy to query ProductPartusing the Projection module in Orchard 1.4.

I want to write ProductServiceand want to query ProductPartwhere the field is IsFeaturedtrue:

contentManager.Query<ProductPart,ProductRecord>().Where(x=>x.IsFeatured).ToList()

How to get it?

+3
source share
2 answers

You can not. Fields stored on the way do not allow them to be requested this way. You can enter IProjectionManager and use the projector request in your service. Or create a FeaturedProduct part, and then query it using the ContetManager.

+3
source

Query generics ( Orchard.ContentManagement)

var products = contentManager.Query<ProductPart, ProductPartRecord>().Where(x => x.IsFeatured).ToList()
+1

All Articles