我正在尝试使用 Razor 在 MVC 中实现一个排序表,但我很难使排序与一些非原始字段一起工作。我的班级模型如下
public class Turma
{
public int ID { get; set; }
public string Ano { get; set; }
[ForeignKey("Professor")]
public int Professor_ID { get; set; }
public virtual Professor Professor { get; set; }
[ForeignKey("Disciplina")]
public int Disciplina_ID { get; set; }
public virtual Disciplina Disciplina { get; set; }
}
public class Professor
{
public int ID { get; set; }
public string Nome { get; set; }
public string Email { get; set; }
public string Telefone { get; set; }
}
public class Disciplina
{
public int ID { get; set; }
public string Nome { get; set; }
}
我正在尝试使用 DbSet 对其进行排序:
turmas = turmas.OrderByDescending(s => s.Disciplina.Nome);
这甚至可能吗?