[CSHARP-2627] MongoDB C# Driver serializing the discriminator twice when discriminator is explicitly declared in the class Created: 05/Jun/19 Updated: 22/Nov/20 Resolved: 25/Jun/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | 2.8.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Sylvain Boissé | Assignee: | Wan Bachtiar |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
.NET Core 2.0 |
||
| Description |
|
I have a base class with a property named Type meant to be used as a discriminator, but that can be used in the C# code to tell what we are dealing with. Say we are dealing with vehicles: } public class Truck: Vehicle { } } |
| Comments |
| Comment by Daigo Kobayashi [ 22/Nov/20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We are trying a similar scenario and facing a same issue. We also have a base class which has enum type field and implemented a custom IDiscriminatorConverntion class.
This works fine for read queries. For example, the following query issue a query like this.
However if we try to create/update a document, it throws "Duplicate element name ..." exception. Other user has already posted an issue:CSHARP-2132. The comment suggests return null on GetDiscriminator. So we've implemented to return null on GetDescriminator then create/update queries work perfect but read query throws following exception.
We've also checked the C# driver source code and the case we've faced is not considered on current version of the driver(2.11.4). Any thoughts? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Rachelle Palmer [ 25/Jun/20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi there, thank you for reaching out to MongoDB. As this sounds more like a support issue, I wanted to give you some resources to get this question answered more quickly:
Thank you! |