开发者

How would I do Subsequent sort on a child table in asp.net mvc2 using Entity Framework

I am trying to do something like this:

 ViewData.Model = _db.Questions  
                     .Include("QType")  
                     .Include("Q开发者_开发百科Tags")  
                     .Include("SubQuestions.Options")  
                     .Where(q => q.Active == true)  
                     .Orderby(q => Questions.Order)  
                     .Orderby(sq => SubQuestions.Order)  
                     .ToList(); 

But ofcourse it is not working as I want to. The Ordering works on Question.Order, but I would also the Questions.SubQuestions list to be ordered according to SubQuestions.Order.

Any blatant mistakes anyone can help me resolve?

Thanks


Is your code accurate? It doesn't look like you're using either q or sq in your order by clauses. I'm pretty sure your problem though is that your second order by should be replaced with the ThenBy operator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜