Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Orden de LINQ por consulta descendente

Estoy seguro de que esto será relativamente simple.

Tengo una consulta LINQ que quiero ordenar por la fecha de creación más reciente.

Ver:

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

También he probado:

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

pero esto da un error:

Sin sobrecarga para el método 'OrderByDescending' toma 0 argumentos

Por lo que he leído, estoy bastante seguro de que la primera forma en que lo hice debería funcionar. Intenté cambiar de descendente a ascendente solo para ver si hace algo, pero sigue igual.

Estaría agradecido si alguien pudiera echar un vistazo a la consulta y ver si estoy haciendo algo mal. Gracias :)

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Debe elegir una propiedad para ordenar y pasarla como una expresión lambda a OrderByDescending

me gusta:

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

Realmente, aunque la primera versión de su declaración LINQ debería funcionar. ¿Está t.Delivery.SubmissionDate realmente poblado con fechas válidas?

over 4 years ago · Santiago Trujillo Report

0

Creo que esto primero falló porque está ordenando un valor que es nulo. Si Entrega es una tabla asociada a una clave externa, entonces debe incluir esta tabla primero, ejemplo a continuación:

 var itemList = from t in ctn.Items.Include(x=>x.Delivery) where !t.Items && t.DeliverySelection orderby t.Delivery.SubmissionDate descending select t;
over 4 years ago · Santiago Trujillo Report

0

Creo que el segundo debería ser

 var itemList = (from t in ctn.Items where !t.Items && t.DeliverySelection select t).OrderByDescending(c => c.Delivery.SubmissionDate);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!