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

Modify BsonClassMapSerializer to handle properties that are grouped in a nested document

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 2.21.0
    • Component/s: Serialization
    • None

      In some cases it can be advantageous to group several properties under a nested document in the serialized form.

      For example, the class:

      public class OrderItem
      {
          public int OrderId { get; set; }
          public int ProductId { get; set; }
          public int Quantity { get; set; }
      }
      

      might need to be serialized as:

      {
          _id :
          {
              OrderId : 1,
              ProductId : 2
          },
          Quantity : 3
      }
      

      While this serialization format could also be achieved by declaring a custom POCO to hold the OrderId/ProductId pair, there are cases where we might want the components of a compound primary key to appear at the top level in the POCO while being grouped together in a nested `_id` element in the serialized form.

      We would like to support this option when using the `BsonClassMapSerializer`. This feature requires changes to the `BsonClassMapSerializer`, as well as adding code and attribute based ways to configure this.

            Assignee:
            Unassigned Unassigned
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: