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

Topics: Writing modules
Jun 4, 2012 at 2:34 PM
Edited Jun 4, 2012 at 2: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
	.ContentPartRecord());

SchemaBuilder.CreateTable("CityPartRecord", table => table
    .ContentPartRecord()
    .Column<int>("CountryPartRecord_id"));

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

As I understand it should looks like following code:

context.Query
    .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?

dfdfdfdfdfCriterionProvidedfsdfrdfa
Coordinator
Jun 4, 2012 at 7: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 10: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.