【发布时间】:2021-07-16 16:18:35
【问题描述】:
ConventionRegistry.Register("IgnoreIfDefault",
new ConventionPack { new IgnoreIfDefaultConvention(true) },
_ => true);
var bsonDocument = anon.ToBsonDocument();
使用 IgnoreIfDefaultConvention 可能会导致意外行为,因为它会影响所有默认值。例如,下面列出的值将不会被保存:
int = 0
decimal = 0
bool = false
如果我只想忽略 空值和空数组,最好的方法是什么?
【问题讨论】:
标签: c# mongodb mongodb-.net-driver bson