Hi guys,
how to set a RepresentationConverter
with allowTruncation
true by default on whole application?
I trying
try { BsonSerializer.RegisterSerializer<Decimal>(new DecimalSerializer(BsonType.Decimal128, new RepresentationConverter(false, true))); }
catch (Exception) { }
but my query is throwing “MongoDB.Bson.TruncationException: Truncation resulted in data loss.” from anonymous class
var customers = from c in _collection.AsQueryable()
join p in i.AsQueryable() on c.Customer equals p.Id
select new
{
Id = c.Id,
Name = p.Name,
Amount = c.Amount - c.ReturnAmount - c.SkipAmount
} into c
group c by c.Name into g
select new
{
Customer = g.Key,
Amount = g.Sum(x => x.Amount)
};
var others = (await customers.OrderByDescending(x => x.Amount).Skip(5).ToListAsync()).Sum(x => x.Amount);