Code
var query = from s in context.Subject.Include("Reply")
where s.Id == subjectId
//orderby s.Reply.OrderBy(r => r.PostTime)
select s;
/*
我想以reply中的posttime排序,但不知道怎么弄。
注:reply的数据类型为System.Data.Objects.DataClasses.EntityCollection<SubjectReply>
*/
//现在我是这样实现的:
var query = from s in context.ZoneSubject.Include("Reply")
where s.Id == subjectId
select s;
Subject subject = query.FirstOrDefault();
if (subject != null)
{
var q = from r in context.SubjectReply
where r.Subject.Id == subjectId
orderby r.PostTime ascending
select r;
foreach (var item in q)
{
subject.Reply.Add(item);
}
}
return subject;
//如何将它改简短点,高人请指点?
开发模式为ado.net entity framework