[CSHARP-4819] ReplaceWith not respecting custom element name configured by the serializer Created: 25/Oct/23 Updated: 06/Nov/23 |
|
| Status: | Investigating |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 2.22.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Wassim Khalil | Assignee: | Robert Stam |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
| Comments |
| Comment by Robert Stam [ 01/Nov/23 ] | ||||
|
I'm sorry the workaround doesn't work for you given your architecture. We do plan to address this issue but I'm not sure when. | ||||
| Comment by Wassim Khalil [ 01/Nov/23 ] | ||||
|
Thanks robert@mongodb.com for your detailed response. Unfortunately, the work around you suggested doesn't work for us, as we follow onion architecture in our codebase and the User class lives in the domain layer (at the center of the onion) with no dependencies on the outside world. It's the persistence layer's responsibility to configure the correct mapping and serialization of the domain layer models to various persistence technologies like MongoDB. In other words, the domain layer doesn't have a direct or indirect dependency on MongoDB driver. | ||||
| Comment by Robert Stam [ 31/Oct/23 ] | ||||
|
Thank you for reporting this. I am able to reproduce it. This is going to be non-trivial to fix. Currently we create a new class map when translating an `Expression` that calls a constructor. The reason we do that is that we want to make sure that the serializer we create to handle the result correctly deserializes all inputs to the constructor (which might be serialized in custom ways). I realize that in the case of `ReplaceWith` what we really need is to make sure the result is compatible with the collection's document serializer. As a partial workaround you could use an attribute instead of the code you have in a constructor:
| ||||
| Comment by PM Bot [ 25/Oct/23 ] | ||||
|
Hi wassimk@vypex.com, thank you for reporting this issue! The team will look into it and get back to you soon. |