-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.7
-
Component/s: Feature Request
-
None
-
Environment:any
If there are documents in Mongo, and the C# driver tries to create them into .NET classes that have "not enough" properties, the c# driver currently throws an exception. This is a problem in many cases.
Someone has asked for this before, but was told that this was "by design" and that using the [BsonIgnoreExtraElements] attribute on the .NET class would solve the problem. It does, BUT.....
I find this solution to be distasteful in the extreme because it ties the c# object model to Mongo. The model must have a dependency on the mongo dll that contains the attribute. This effectively prevents me from being able to use that attribute at all.
Which means that migrating data is extremely painful when it involves removing properties from the model that have already been saved in Mongo.
It would be MUCH better, if at the driver level, in the code, I could say something like:
database.GetCollectionIgnoringExtraElements
or
collection.IgnoreExtraElementsWhenDeserializing
or
whatever.YouGetTheIdea()
The whole point being - some way other than by adding a dependency on my model to Mongo, to achieve this goal. It would make migrations to the model MUCH EASIER. And would allow us to continue our adoption of Mongo.
- related to
-
CSHARP-1478 BsonClassMap.Reset() is not consistent with default constructor
- Closed