Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda