-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving nested items with class hierarchies #2985
Comments
Reproducible using below code: using System;
using System.Collections.Generic;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DataModel;
using Amazon.Runtime;
using (AmazonDynamoDBClient client = new AmazonDynamoDBClient())
{
DynamoDBContext context = new DynamoDBContext(client);
var a1 = new A { Name = "A1" };
var b1 = new B { Name = "B1" };
Guid id = Guid.NewGuid();
var model = new ModelA
{
id = id,
MyClasses = new List<A> { a1, b1 }
};
await context.SaveAsync(model);
}
public class A
{
public string Name { get; set; }
public int MyPropA { get; set; } = 1;
}
public class B : A
{
public int MyPropB { get; set; } = 2;
}
[DynamoDBTable("Test")]
public class ModelA
{
[DynamoDBHashKey]
public Guid id { get; set; }
public List<A> MyClasses { get; set; }
} Unsure if this is by design due to limitation mentioned in #245 (comment). Needs review with the team. |
Looks like it a common issue for dynamoDB sdk of different languages. |
This has been released in the latest preview of V4: https://www.nuget.org/packages/AWSSDK.DynamoDBv2/4.0.0-preview.9 Thanks again @irina-herciu for the contribution! |
Comments on closed issues are hard for our team to see. |
Describe the bug
This is a similar issue to a very old discussion posted here on class hierarchies in Dynamo, but this one is explicitly about saving items. I am trying to use DynamoDB to save a model that mimics the following structure
If we instantiate a new instance of this model like so...
We end up with a list that contains both Class B & Class A types that are being saved into Dynamo incorrectly.
Expected Behavior
Expectation would be for both Model A & Model B to save with the properties that are pushed by the code and be able to recognize the Model B inheritance
Current Behavior
When this model is saved to Dynamo it only saves the Class A properties. Here's a screenshot showing what the object looks like when the Save call is made vs what it looks like within Dynamo
Reproduction Steps
See above
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.DynamoDBv2 3.7.104
Targeted .NET Platform
.NET 7
Operating System and version
Windows 10
The text was updated successfully, but these errors were encountered: