Solved

Need Order by in LINQ

Posted on 2014-03-10
3
323 Views
Last Modified: 2016-02-10
New to Linq.

I need to add an order by on the new  AppResourceDetails().Need to order by on arg.GroupDescription

appResourceDetails = context.AppResources                    
                        .Where(ar => ar.AppId == appId && ar.GroupId != UserDefinedReports)
                        .Join(context.AppResourceGroups, ar => new { ar.GroupId, ar.AppId }, arg => new { arg.GroupId, arg.AppId },
                        (ar, arg) => new AppResourceDetails()
                        {
                              ResourceId = ar.ResourceId,
                              ResourceTypeId = ar.ResourceTypeId,
                              ResourceDescription = ar.ResourceDescription,
                              ResourceComment = ar.ResourceComment,
                              CreateDate = ar.CreateDate,
                              ExpirationDate = ar.ExpirationDate,
                              GroupId = ar.GroupId,
                              GroupDescription = arg.GroupDescription
                        }).ToList();

Appreciated
thank you
0
Comment
Question by:Charles Baldo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39917984
Try it like this:

appResourceDetails = context.AppResources                    
                        .Where(ar => ar.AppId == appId && ar.GroupId != UserDefinedReports)
                        .Join(context.AppResourceGroups, ar => new { ar.GroupId, ar.AppId }, arg => new { arg.GroupId, arg.AppId },
                        (ar, arg) => new AppResourceDetails()
                        {
                              ResourceId = ar.ResourceId,
                              ResourceTypeId = ar.ResourceTypeId,
                              ResourceDescription = ar.ResourceDescription,
                              ResourceComment = ar.ResourceComment,
                              CreateDate = ar.CreateDate,
                              ExpirationDate = ar.ExpirationDate,
                              GroupId = ar.GroupId,
                              GroupDescription = arg.GroupDescription
                        }).OrderBy(gd => gd.GroupDescription).ToList();

Open in new window

0
 

Author Closing Comment

by:Charles Baldo
ID: 39918208
Perfect,  Thank you kindly
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39918291
Not a problem, glad to help.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question