开发者

Linq to Entities Include and Ordery By

开发者 https://www.devze.com 2022-12-09 21:41 出处:网络
I\'m using the query below: public IEnumerable<QUESTIONARIO_BASE> L开发者_如何学运维istQuestionario()

I'm using the query below:

public IEnumerable<QUESTIONARIO_BASE> L开发者_如何学运维istQuestionario()
{
    var query = (from c in _entities.QUESTIONARIO_BASESet
                             .Include("QUESTAO_BASE")
                             .Include("QUESTAO_BASE.DIMENSAO")
                             .Include("QUESTAO_BASE.RESPOSTA_BASE")
                         select c);

    return query.ToList();
}

And wants to order the sub sets QUESTAO_BASE and QUESTAO_BASE.RESPOSTA_BASE.

After google a lot and use much of examples found here I still not figure out how to accomplish this.

Anyone knows how to order the subsets and return a typed data?


You always can change the order of collections in your view layer.

Ex:

foreach (var item in Model){
{
    foreach (var itemQuestaoBase in **item**.QUESTAO_BASE.OrderBy(a => a.ORDEM)){
         //DO STUFF IN VIEW
    }
}


Use this tip: How to sort Relationships in Entity Framework

0

精彩评论

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