5

I am having trouble moving between mongodb and json.net due to polymorphic types. the c# mongodb driver users _t as the discriminator property name and json.net uses $type. I know json.net has this value hardcoded from other research. My question is if anyone knows of a way to rename "_t" to "$type" using the c# mongodb driver?

4

1 回答 1

9

我相信您可以创建自定义鉴别器约定,并且可以将其添加到您希望修改的每种类型中;

http://mongodb.github.io/mongo-csharp-driver/2.2/reference/bson/mapping/polymorphism/

这是一个可能对您有所帮助的自定义鉴别器约定的示例;

http://pastebin.com/9UweEKBe

于 2013-07-09T01:31:13.603 回答