Как сделать заказ по вложенному свойству коллекции. В моем случае, если у ученика нет отметок, это выдает ошибку, из-за которой необходимо упорядочить хотя бы один элемент. Как я могу заказать по CurrentMark?
public IEnumerable<Student> Get(Expression<Func<Student, bool>> expr = null,
Func<IQueryable<Student>, IOrderedQueryable<Student>> orderBy = null,
Func<IQueryable<Student>, IIncludableQueryable<Student, object>> includes = null)
{
var repo = _unitOfWork.GetRepository<Student>();
var students= repo.GetPagedList(expr, orderBy, includes)
.Items;
return students;
}
public void Main()
{
Get(expr: null, orderBy: orderBy => orderBy.OrderBy(mark => mark.Marks.OrderBy(curr => curr.CurrMark)));
//over here i came across an error
}
public class Student
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public ICollection<Mark> Marks { get; set; }
}
public class Mark
{
public int Id { get; set; }
public int CurrMark { get; set; }
public int StudentId { get; set; }
public Student Student { get; set; }
}