-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Serialization
-
Labels:None
When using the insertOne function in the C# driver, in case we initialize an array with {{new[]
{obj, obj, obj}}}. The _t Discriminator is missing in the DB.
for example:
collection.InsertOne(new Parent { Children = new[] { new Child() } });
will save to DB:
{"_id":"5bf6aef6c0beccc414b70d45","Child":[{}]}
The problem does not happen when using List
collection.InsertOne(new Parent { Children = new List<IChild> { new Child() } });
will insert into DB:
{ "_id":"5bf6b074c0beccc414b70dc2", "Children":[{"_t":"Child"}]}
for further information please check this StackOverflow question: