简体   繁体   English

MongoDB F#IgnoreExtraElements

[英]MongoDB F# IgnoreExtraElements

I am using the MongoDB.Fsharp Driver and I've got some fields in newer records that I don't have in older records for a given collection. 我正在使用MongoDB.Fsharp驱动程序,并且在给定集合的较旧记录中没有新记录中的某些字段。

So when I want to create a query that includes older records, it gives me the following exception: MongoDB.Bson.BsonSerializationException: No matching creator found. 因此,当我想创建一个包含旧记录的查询时,它给了我以下异常:MongoDB.Bson.BsonSerializationException:没有找到匹配的创建者。

I've googled around and apparently I need to add the below code but it still doesn't work. 我已经四处搜寻,显然我需要添加以下代码,但是它仍然无法正常工作。 I've also tried to annotate the type with the BsonIgnoreExtraElements atrribute but that does not work either. 我也尝试使用BsonIgnoreExtraElements属性来注释类型,但这也不起作用。

let pack = ConventionPack();
pack.Add(IgnoreExtraElementsConvetion(true))
ConventionRegistry.Register("IgnoreExtraElements", pack, (fun -> _ -> true))

Don't know if this is relevant but should 不知道这是否相关,但应该

IgnoreExtraElementsConvetion

be

IgnoreExtraElementsConve**n**tion

?

Also - and this is a total guess, should 另外-这是一个总的猜测,应该

(fun -> _ -> true)

be

(fun _ -> true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM