开发者

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

开发者 https://www.devze.com 2023-01-17 07:47 出处:网络
I am trying to do something like this: ViewData.Model = _db.Questions .Include(\"QType\") .Include(\"Q开发者_开发百科Tags\")

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

精彩评论

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