[CSHARP-4757] Modify BsonSerializationInfo to handle properties that are grouped in a nested document Created: 17/Aug/23  Updated: 14/Sep/23  Resolved: 14/Sep/23

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: 2.21.0
Fix Version/s: 2.22.0

Type: Improvement Priority: Unknown
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by EF-35 Composite key reading Closed
is depended on by EF-36 Query against composite key components Closed
Related
related to CSHARP-4758 Modify BsonClassMapSerializer to hand... Backlog
Documentation Changes: Not Needed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

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.



 Comments   
Comment by Githook User [ 14/Sep/23 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4757: Modify BsonSerializationInfo to handle properties that are grouped in a nested document.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/e9cb7b707cbdb3195cff3d6c665835d63f15de0f

Generated at Wed Feb 07 21:49:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.