Thanks. I was able to also reproduce the sample I provided with no errors. I then started digging some more, and found the deserialization error was getting throws because objects in my collection were originally created when the class did NOT use interfaces. As a result, the “_t” was not in the bson doc.
Here is a snippet of a the bson doc that gets created after modifying my c# class to use interfaces (Notice the ** “_t”:”Location” **). I really wish (is there??) there were a way to tell mongo that certain ‘properties’ in a bson document should be deserialized out to a specify type. Otherwise, I have to re-create all my documents in the collection. Any thoughts on that?
{
"_id" : ObjectId("4fad3b57b71e9a2bb038e069"),
"Status" : "A",
"ClassCodeObjId" : ObjectId("4fad3343b71e9a2bb038d73c"),
"AnimalId" : "2370000028375",
"SpeciesId" : "Swine",
"CompanyId" : "Newsham",
"BloodLineId" : "PTRN",
"BirthDt" : new Date("9/19/2009 19:00:00"),
"Gender" : "F",
"SireCompanyId" : "Newsham",
"SireBloodLineId" : "PTRN",
"SireLineId" : "EBX",
"SireAnimalID" : "2360000017205",
"DamCompanyId" : "Newsham",
"DamBloodLineId" : "PTRN",
"DamLineId" : "EBX",
"DamAnimalID" : "2370000018407",
"CurrentLocation" : {
"_t" : "Location",
"_id" : ObjectId("4fad3378b71e9a2bb038e003"),
"CompanyId" : "Newsham",
"FarmID" : "25037",
"IsActive" : true
},
"AddDt" : new Date("5/11/2012 11:16:23"),
"AddBy" : "pbrower",
"ModDt" : new Date("5/11/2012 11:16:23"),
"ModBy" : "pbrower"
}
Paul Brower | Director
of Information Technology
Newsham Choice Genetics
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/mongodb-user/-/Vsio0I82paQJ.
To post to this group, send email to
mongod...@googlegroups.com.
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mongodb-user?hl=en.
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
Can the descriminators be set via attributes in the interface or class so that the “_t” doesn’t have to exist in the bson doc?
Paul Brower | Director
of Information Technology
Newsham Choice Genetics
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mongodb-user?hl=en.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/tL8pjOt90cMJ.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/tL8pjOt90cMJ.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.