score:2
Rewrite your query to select DTO after ordering:
var longRunningQueries = context.TblMessageQueues
.GroupBy(x => x.SequencingQueue)
.Select(g => new {
DateDiff = DbFunctions.DiffMonths(g.Min(x => x.QueuedTime), g.Max(x => x.QueuedTime)),
SequencingQueue = g.Key
}).OrderByDescending(a => a.DateDiff)
.Select(t => new TblMessageQueueDto {
DateDiff = t.DateDiff,
SequencingQueue = t.SequencingQueue
}).ToList();
Source: stackoverflow.com
Related Query
- linq is taking long to order by datediff
- Linq query taking too long
- LINQ Source Code Available
- Linq 'contains' query taking too long
- creating Linq to sqlite dbml from DbLinq source code
- Linq join between IQueryable and List<int> is taking too long to be executed
- LINQ DBcontext is taking too long to load data
- GROUP BY, ORDER BY and taking first in LINQ
- Parallel LINQ GroupBy taking long time on systems with high amount of cores
- source code for LINQ 101 samples
- LINQ query to retrieve pivoted data taking too long
- Linq query taking a long time to query a table with 6000 records
- Will Linq query code in C# UWP project work slower or faster depending on order of its' parts?
- LINQ to Entities Select taking a long time
- How can I order the output of my long LINQ query by a double and then a string?
- Linq Query is taking long time
- c# Linq or code to extract groups from a single list of source data
- The background task I am running in my asp.net application is taking long time to execute and is getting stuck at a linq query
- Linq query taking too long to process results
- Linq Update taking long time to process
- Preserving order with LINQ
- Convert string[] to int[] in one line of code using LINQ
- Multiple Order By with LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- LINQ order by null column where order is ascending and nulls should be last
- Linq to Objects: does GroupBy preserve order of elements?
- Linq order by boolean
- Does the order of LINQ functions matter?
- Linq code to select one item
- C# - code to order by a property using the property name as a string
More Query from same tag
- How to set conditional filter in where clause using linq?
- How to make this LINQ To entity method work when it has Nullable LEFT JOIN
- LINQ to Entities v/s ADO.Net
- Linq to SQL: Using int? as a parameter in a query
- Linq Sql Int null equal to null. Not returning rows
- How to convert System.Data.Linq.Binary to a Stream?
- Need a LINQ code example to link two tables that have no foreign key
- Linq to get immediate children in Nested Set Model
- AsNoTracking using LINQ Query syntax instead of Method syntax
- Lambda Expression LINQ Equivalent to SQL Exists Query on Same Table/Variable
- How to discover financial Year based on current datetime?
- Identify methodinfo that has HTTPPost() attribute
- How can I use LINQ to just return one row from a selection?
- How to use anonymous types with Netflix OData API
- When is OnValidate called in Linq?
- How to save and reuse an IQueryable, or it's Where clause?
- How to return IList<T> in Lambda query for this program
- Creating Panel with images and linkbutton at runtime
- Where clause on list property
- How to use group by on a DataTable in LINQ?
- Get List of Dicionary Value Property in c# using List of Keys
- Implementing the Choice Type in C#
- Optimize Sitecore Lucene / Solr query
- Linq to Xml and Namespace prefixes
- using Linq To Sql to save to an SDF (local database file) in .Net
- using where clause after get last record?
- Show 3 result from each element in group by
- Linq query of left outer join not properly working
- List Collection Filtering using Where condition giving null values
- How to output Property not included in group by and its count