How to query content items based on URL in a projection?

Topics: General
May 5, 2015 at 1:49 PM
I would like to be able to filter a projection based on the page URL. So, for example, I could have a projection return all pages that start with /news such as /news/item-one and /news/item-two.

The only way I know how to attempt to achieve this would be by creating a custom IFilterProvider. So I have created a custom IFilterProvider where I can specify the URL. However in my custom filter I do not know how to query for the all pages starting with a URL using an Hql query.

I want to do something like
contentManager.Query<AutoroutePart, AutoroutePartRecord>().Where(x => x.DisplayAlias.StartsWith(url));
But using HqlQuery. My filter provider contains
public void ApplyFilter(FilterContext context) 
    // ...
    context.Query // ... the IHqlQuery I need to filter with
    // ...
How can I query all content items with a autoroute part with a permalink starting with a specified string?
May 5, 2015 at 2:36 PM
After a bit of digging around, I found this works
context.Query = context.Query.Where(alias => alias.ContentPartRecord<AutoroutePartRecord>(), expr => expr.Like("DisplayAlias", pageUrl, HqlMatchMode.Start));