Skip to content
Fix Code Error

LINQ Orderby Descending Query

March 13, 2021 by Code Error
Posted By: Anonymous

I’m sure this will be a relatively simple one.

I have a LINQ query that I want to order by the most recently created date.

See:

        var itemList = from t in ctn.Items
                        where !t.Items && t.DeliverySelection
                        orderby t.Delivery.SubmissionDate descending
                        select t;

I have also tried:

       var itemList = (from t in ctn.Items
                        where !t.Items && t.DeliverySelection
                        select t).OrderByDescending();

but this gives an error :

No overload for method
‘OrderByDescending’ takes 0 arguments

From what I’ve read, I’m fairly sure the first way I’ve done it should work. I’ve tried changing descending to ascending just to see if it does anything but it stays the same.

I’d be grateful if someone could take a look at the query and see if I’m doing anything wrong. Thanks 🙂

Solution

You need to choose a Property to sort by and pass it as a lambda expression to OrderByDescending

like:

.OrderByDescending(x => x.Delivery.SubmissionDate);

Really, though the first version of your LINQ statement should work. Is t.Delivery.SubmissionDate actually populated with valid dates?

Answered By: Anonymous

Related Articles

  • Continuous Integration vs. Continuous Delivery vs.…
  • LINQ query to select top five
  • Backbone.js backed list not being refreshed by…
  • Problems deserializing Newtonsoft JSON in c# returning null
  • Overload resolution between va_list and ellipsis…
  • Dynamic LINQ OrderBy on IEnumerable / IQueryable
  • Group array of objects by multiple keys using d3.groups
  • ascending/descending in LINQ - can one change the…
  • error LNK2005: ✘✘✘ already defined in…
  • Is this request generated by EF Core buggy or is it my code?
  • D3 chart integration into Vuejs
  • having problem with .value and textContent
  • HTTP Status 405 - Request method 'POST' not…
  • Custom date picker in Vuetify
  • Convert Java Date to UTC String
  • Why is it that "No HTTP resource was found that…
  • Getting the difference between two Dates…
  • How to avoid duplicates in list python?
  • How To Edit Date and Time Picker Vuejs Vuetify From…
  • How to convert java.util.Date to java.sql.Date?
  • python 3.2 UnicodeEncodeError: 'charmap' codec can't…
  • OrderBy descending in Lambda expression?
  • RegEx match open tags except XHTML self-contained tags
  • SortableJS / Vue.Draggable multi-drag option not working
  • How to access data returned from an API using jQuery
  • The number of method references in a .dex file…
  • Can't install via pip because of egg_info error
  • How do I modify elements in an array that is managed…
  • How can I do an OrderBy with a dynamic string parameter?
  • Rails Active Record find(:all, :order => ) issue
  • Dynamic LINQ instead of ExecuteSqlRaw
  • SQL query return data from multiple tables
  • How to get dynamic column data linq
  • Ember - how to use pushObject on nested data object?
  • Smart way to truncate long strings
  • How to make Lodash sortBy() to sort data to…
  • Iterate an array using only select query in teradata
  • bootstrap-datepicker in dd/mm/yyyy - selected date…
  • Create a custom hidden field in backend product…
  • Consider defining a bean of type 'package' in your…
  • Using .Select and .Where in a single LINQ statement
  • Using query strings in backbone (1.0.0)
  • Sort a list of numerical strings in ascending order
  • C# list.Orderby descending
  • Display images from Firebase Storage order by date…
  • Change the atribute of the xml tree in python
  • Vuetify - Rules should return a string or boolean,…
  • How to get WooCommerce order details
  • Chunk and excel Laravel
  • Vue dynamic v-model within v-for
  • Material-ui Table sorting not working reactjs
  • BigQuery: user metadata described by start date and…
  • How to sort a dataFrame in python pandas by two or…
  • Android Firestore query paging…
  • The definitive guide to form-based website authentication
  • vuetify data table pagination custom function
  • .Net Core 3.1 Entity Framework Slow Query Problem
  • Regex for headings and sub headings in Python to get…
  • sorting and paging with gridview asp.net
  • Vue js v-bind to function not working?
  • Fix a compile error when comparing a T[keyof T] and…
  • Sorting backbone collections with multiple attributes
  • For-each over an array in JavaScript
  • Binding an ember model's date attribute to…
  • Angular - Can't make ng-repeat orderBy work
  • How can I sort generic list DESC and ASC?
  • java.lang.RuntimeException:…
  • Is it possible to send a variable number of…
  • Sorting by date & time in descending order?
  • Query based on multiple where clauses in Firebase
  • Selecting range by finding start/end row number…
  • Angular.js and HTML5 date input value -- how to get…
  • how to make column bool data to be true with the…
  • data.table vs dplyr: can one do something well the…
  • Inconsistent accessibility: property type is less accessible
  • Invoke native date picker from web-app on iOS/Android
  • The second execution of jquery datatable dont redraw…
  • Removing an array item from Firestore not working…
  • Server side implementation for Rest Api
  • How to retrieve data in Firebase Real-time Database
  • How to pass all arguments passed to my bash script…
  • Unable to make typescript recognize typing
  • Adding numbers and receiving a NaN
  • So can't use weasyprint what is the best thing to do?
  • How to add pagination on vue-tables-2 using Laravel…
  • Entity Framework VS LINQ to SQL VS ADO.NET with…
  • Vue.js: can't orderBy in v-for
  • useEffect Error: Minified React error #321 (GTM…
  • AppCompat v7 r21 returning error in values.xml?
  • Subtracting Dates in Oracle - Number or Interval Datatype?
  • How to implement the factory method pattern in C++ correctly
  • multiple login routes using ember-cli-simple-auth
  • How to prevent scrolling the whole page?
  • Database development mistakes made by application developers
  • Querying previous row of data if data is not…
  • How to filter a RecyclerView with a SearchView
  • Using LINQ to find item in a List but get "Value…
  • Cannot read property slug of undefined
  • Converting between java.time.LocalDateTime and…
  • Ember.js Computed property does not update hasMany…

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How to print to stderr in Python?

Next Post:

Get list from pandas dataframe column or row?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error