This project is read-only.

Sorting in Projection Query in case of one-to-many part relation

Topics: Writing modules
Jun 4, 2012 at 3:34 PM
Edited Jun 4, 2012 at 3:47 PM

I have two related parts: CountryPart and CityPart, titles for city and country store in TitlePart. Threr is record definitions for my custom parts:

SchemaBuilder.CreateTable("CountryPartRecord", table => table

SchemaBuilder.CreateTable("CityPartRecord", table => table

I want to implement ISortCriterionProvider to get City sorted by country title and city title.

As I understand it should looks like following code:

    .Join(x => x.ContentPartRecord(typeof(CountryPartRecord)))
    .OrderBy(x => x.ContentPartRecord(typeof(TitlePart)), x => x.Asc("Title"));

But it does not work.

How to write IHqlQuery for sorting by related ContentParts?
Could you advice some sample or doc to write ISortCriterionProvider?

Jun 4, 2012 at 8:12 PM

Join in this context is for joining parts within a single item, not to handle part to part relationships across items.

Jun 5, 2012 at 11:55 AM

Ok, but could you direct me how to make join in ISortCriterionProvider? May be I'm missing some documentation about querying in Orchard CMS.