Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
How to Sort Mongo collection in F#

I can get a collection in MongoDB using F# No problem using

let draws = db.GetCollection<Draw>("draws").Find(fun _ -> true)

To Sort I would expect it to be:

let draws = db.GetCollection<Draw>("draws").Find(fun _ -> true).Sort(Builders<Draw>.Sort.Descending(d => d.drawDate))

But I am getting the following error. In the intellisense all of the types seem to be recognised all the way through so I am not sure what to do.

A unique overload for method 'Descending' could not be determined based on type information prior to this program point. A type annotation may be needed.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Your second lambda is using C# syntax. I'm not sure if that's what's causing the compiler error, but I think it's easier to do something like this anyway:

let draws =
    db.GetCollection<Draw>("draws")
        .Find(fun _ -> true)
        .SortByDescending(fun d -> d.drawDate :> obj)

(Note that the SortByDescending function requires a result of explicit type object, but it shouldn't cause any problems for you. I think this is because the driver was created with C# clients in mind, where the upcast is implicit.)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda