This project is read-only.

SortQuery for many-to-many relation

Topics: Customizing Orchard, Writing modules
Sep 7, 2012 at 3:47 PM
Edited Sep 7, 2012 at 3:51 PM


I have the following problem:
I have a part that displays one or more dates. I created  a many-to-many relationship.

public class EventPartRecord : ContentPartRecord
    public virtual IList<ContentEventDatesRecord> Dates { get; set; }
public class EventDateRecord 
{ public virtual int Id { get; set; } public virtual DateTime Date { get; set; } }
public class ContentEventDatesRecord
  public virtual int Id { get; set; }
  public virtual EventPartRecord EventPartRecord { get; set; }
  public virtual EventDateRecord EventDateRecord { get; set; }
Everything works fine. Now I want to have a query for sorting my items. The criteria for sorting should use this date: Dates.Where(d => d.EventDateRecord.Date >= DateTime.Today).OrderBy(d => d.EventDateRecord.Date).FirstOrDefault(); I have no Idea how I can do this in the ISortCriterionProvider.
Sep 29, 2012 at 9:24 AM

Did you have a look at existing implementations of ISortCriterionProvider?

Nov 7, 2012 at 10:45 PM

Sorry for late reply. I took a look, but I don't know how I can join these Tables in the SortCriterionContext.

Anybody a hint?