LINQ “.Include” orderby in subquery

后端 未结 3 1617
天命终不由人
天命终不由人 2021-01-12 07:33

I have the following entity code, which returns all users and \"includes\" all of their sample requests:

    var userQuery = from u in _IntranetContext.UserS         


        
3条回答
  •  逝去的感伤
    2021-01-12 08:24

    Just add another ordering parameter to the orderby:

    var userQuery = from u in _IntranetContext.UserSet.Include("SampleRequests")
                               orderby u.LastName ascending, 
                                       u.SampleRequestId descending
                               select u;
    

提交回复
热议问题