One common use-case for attempting migrations is for things like renaming fields. If you rename a property from `OldName` to `NewName`, the existing documents won't have been updated so `NewName` will typically be null.
The defensive coding argument is to use [MongoExtraElements] attribute to fill a dictionary and update your CLR object accordingly.
The issue with the defensive coding strategy is that you can't query against `NewName` until the object has been updated & saved. Most documents may take a while before they're upgraded, and some may never be upgraded. In the meantime, we would have to sprinkle all of our queries with `Query.OR(Query.EQ("NewName", "foo"), Query.EQ("OldName", "foo"))`.
I propose that we solve this querying issue by updating the Linq driver to automatically do (x.NewName == "foo" || x.OldName == "foo") whenever a field has been renamed. To rename a field, I propose a [MongoOldName(<old-name>)] attribute.
I believe that this case of renaming a field is very common. Due to the nature of Mongo, I also think it's best to implement this at the driver level.
- duplicates
-
CSHARP-487 Add multiple fields search support for LINQ provider
- Closed
- is duplicated by
-
CSHARP-1024 Provide a way to allow alternate field names to ease schema migration
- Closed