Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need Order by in LINQ

Posted on 2014-03-10
3
Medium Priority
?
340 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
  • 2
3 Comments
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 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 64

Expert Comment

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

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

885 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