Details
-
New Feature
-
Resolution: Gone away
-
Unknown
-
None
-
None
-
None
-
None
Description
Summary
ISupportInitialize methods are not called when document class derives from Dictionary<string, object>.
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
MongoDB.Driver 2.17.1
How to Reproduce
Consider following document class:
public class MyType: Dictionary<string, object>, ISupportInitialize
{{{}}
[BsonId]
public string Id
{
get => (string)this["id"];
set => this["id"] = value;
{{ }}}
public void BeginInit()
{
// this never gets executed:
throw new NotImplementedException();
{{ }}}
public void EndInit()
{
// this never gets executed:
throw new NotImplementedException();
{{ }}}
}
Now enumerating the collection deserializes the items correctly as Dictionary objects, but BeginInit() and EndInit() never get called.
Additional Background
Please provide any additional background information that may be helpful in diagnosing the bug.