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

280
Vistas
C# MongoDB UpdateManyAsync with Set method throws an exception

I use c# mongodb driver. When I want to update my specific values, it throws an exception. I used this before but I don't now how but i didn't get any error before. Here's my code:

var result = await col.UpdateManyAsync(
      p => p.X > 5, 
      Builders<Payment>.Filter.Gt(p => p.Amount, 100).Set("Level", "High")
);

And here's my Payment class:

public class Payment
    {
        public ObjectId Id { get; set; }
        public decimal Amount { get; set; }
        public Type Type { get; set; }
    }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You don't have Level property in your Payment class. If this is exactly what you want to do, then you need to add BsonIgnoreExtraElements attribute to your Payment class otherwise it throws an error as follows:

[BsonIgnoreExtraElements]
public class Payment
{
    public ObjectId Id { get; set; }
    public decimal Amount { get; set; }
    public Type Type { get; set; }
}
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