Insert with NominalType parameter

10 views
Skip to first unread message

TM

unread,
Aug 9, 2012, 8:51:33 AM8/9/12
to mongodb...@googlegroups.com
Hi,

I just tried to use the Insert method on MongoCollection and was wondering what the nominalType parameter is for. I thought, that I can use it to give the method another type than the actual object and was hoping that not all the fields of the actual type get serialized but only the fields of the nominalType. When this is not the intention, what is the nominalType parameter used for?

In my special case I'm passing in a base type of the object to insert as nominal type.

While debugging I found a little bug in BsonClassMapSerializer in line 341:

                var actualType = (value == null) ? nominalType : value.GetType();

(value == null) is always false because the line is in the else block of a "if (value == null)".

Regards

PS: I'm using f81e9d9e5fcc937cc88365df147473044dd8076f from 8.8.2012

craiggwilson

unread,
Aug 9, 2012, 9:23:21 AM8/9/12
to mongodb...@googlegroups.com
Well, not exactly a bug, just an if check that doesn't need to be there :)

Nominal Type is used to determine whether not discrminators are necessary when persisting the type.  So, with a Hierarchy of A -> B -> C, then using an instance of C with a nominal type of A would save all the mapped properties/fields of A, B, and C and included a discriminator for C.
Reply all
Reply to author
Forward
0 new messages