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

Support for readonly properties/fields that contain instances

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Serialization
    • None

    Description

      We are dealing with lots of entities that create instances for contained properties/fields as part of their instantiation like this:

      public List<int> Foo { get; } = new List<int>();
      

      or more generic

      public SomeType Bar { get; } = new SomeType();
      

      The C# driver is able to serialize these properties nicely once we map them explicitly. However, they are considered readonly so deserialization gets skipped and our entities end up with not populated instances.

      In order to solve this, we would suggest to enhance the driver in a way that - similar to SetIgnoreIfNull - one can select to skip the instantiation of a type and populate an existing instance on the target object.

      Let me know your thoughts. I'd be happy to implement that right away if you agree.

      Attachments

        Activity

          People

            james.kovacs@mongodb.com James Kovacs
            daniel.hegener@gmx.net Daniel Hegener
            Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: