Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-769

Option, attribute, or convention to suppress discriminator in certain classes

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.6
    • Component/s: None
    • Labels:
      None
    • Environment:
      All

      It would be useful to have a way to suppress the discriminator for certain classes.

      In my case, all classes that are to be stored in Mongo are descended from an abstract class that "knows" how to store things to Mongo:

      It will store to a collection name based on the actual class name
      It knows how to maintain housekeeping fields like CreateDate, LastUpdateDate, _id generation, and self-Archival and numbering of archive versions.

      These are quite useful in this particular project, and it would be pretty painful to have to implement for each class to be saved to the database (there are currently about 14).

      Because all the business objects are derived from this abstract class, the driver adds a discriminator to each record when it is serialized. This is quite unnecessary, since each actual class is saved to a separate collection.

      Can an option be added to the serializer or ClassMap classes, or conventions or attributes, that would allow suppression of these discriminators? Or is there a way of doing that already?

      I already tried defining a ShouldSerialzet or ShouldSerialize_t method in the base class, but that doesn't seem to do it.

            Assignee:
            sridhar Sridhar Nanjundeswaran
            Reporter:
            curt Curt Mayers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: