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
Solved

Need Order by in LINQ

Posted on 2014-03-10
3
312 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:charlesbaldo
  • 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:charlesbaldo
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Backup & Restore 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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

791 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