[英]How to sort records in Composite object?
假设我在DB中有2个表:Student,StudentCourse。
在学生的元数据中,将StudentCourse设置为Composite:
[Include]
[Composition]
public EntityCollection<StudentCourse> StudentCourses { get; set; }
在学生的域服务中,包括StudentCourse,例如:
public IQueryable<Student> GetStudentByID(int id)
{
reutrn this.ObjectContext.Students.Include("StudentCourse").Where(s => s.ID == id) as IQueryable<Student>;
}
问题是:我想对StudentCourse的记录可以按StudentCourses中的列进行排序,例如CourseID。
一个学生下的StudentCourse记录实际上是StudentCourse的实体集合。
如何解决这个问题?
您要问的内容即使在普通SQL中也无法实现。 您可以尝试您的提供者是否会支持这样的东西
this.ObjectContext.Students.Include("StudentCourse").Where(s => s.ID == id).OrderBy(x=> x.StudentCourse.First().CourseId) as IQueryable<Student>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.