Hello! I have an AutoQuery that includes a joined entity, and I would like to order the query results by one of the properties of the joined enttiy. I’m having trouble finding whether this can be achieved or not using the OrderBy property of the query. Here are my classes:
[Alias("Samples")]
public class SampleEntity
{
[AutoId]
public Guid Id { get; set; }
[Index(Unique = true)]
[StringLength(50)]
public string SequenceNumber { get; set; }
[StringLength(1024)]
public string Description { get; set; }
public DateTime DateSubmitted { get; set; }
[Reference]
public ProjectEntity Project { get; set; }
[ForeignKey(typeof(ProjectEntity), OnDelete="NO ACTION")]
public Guid ProjectId { get; set; }
public ulong RowVersion { get; set; }
}
[Alias("Projects")]
public class ProjectEntity
{
[AutoId]
public Guid Id { get; set; }
[Index(Unique = true)]
public string Name { get; set; }
public bool Active { get; set; }
[Reference]
public List<SampleEntity> Samples { get; set; }
}
And here is the query:
[Route("/autoquery/samples")]
[Authenticate]
[RequiredRole("user")]
public class SamplesViewQuery : QueryDb<SampleEntity>, ILeftJoin<SampleEntity, ProjectEntity> { }
The query returns the results as expected, and I can OrderBy all the columns directly in the SampleEntity. I’ve tried using “OrderBy=ProjectName” and “OrderBy=Project.Name” which return the error that the field could not be found. Is there any easy way to perform this sort without having to override the query? Thanks in advance for any ideas!