-
Notifications
You must be signed in to change notification settings - Fork 862
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
DynamoDB SDK convert Nullable DateTime to Local #3351
Comments
Needs reproduction. |
Hello @nazarii-piontko, Thank you for reporting this issue. I am able to reproduce it using below code sample. static async Task Main(string[] args)
{
var dynDbClient = new AmazonDynamoDBClient();
var dynDbContext = new DynamoDBContext(dynDbClient, new DynamoDBContextConfig
{
RetrieveDateTimeInUtc = true
});
var user = new User
{
UserId = Guid.NewGuid(),
AppointmentDateTime = DateTime.Parse("2024-06-24T08:00:00.000Z", styles: DateTimeStyles.AdjustToUniversal)
};
await dynDbContext.SaveAsync(user);
var dbUser = await dynDbContext.LoadAsync<User?>(user.UserId);
Console.WriteLine("AppointmentDateTime: "+dbUser.AppointmentDateTime);
}
[DynamoDBTable("users")]
public class User
{
[DynamoDBHashKey("userId")]
public Guid UserId { get; set; }
[DynamoDBProperty("appointmentSlot")]
public DateTime? AppointmentDateTime { get; set; }
} Before running the code sample, created DynamoDB table with name Execution Result: The .NET SDK team will investigate and work on the fix for this. Thanks again for reporting this case with the Nullable DateTime scenario. Regards, |
We have released a fix for this issue in AWSSDK.DynamoDBv2 3.7.304.1 |
Comments on closed issues are hard for our team to see. |
Describe the bug
The DynamoDB SDK ignores
RetrieveDateTimeInUtc = true
inDynamoDBContextConfig
when serialized/deserialized property has typeDateTime?
(nullable DateTime).Expected Behavior
The DynamoDB SDK should not convert
DateTime?
saved in the table as UTC to Local time upon retrieval whenDynamoDBContextConfig.RetrieveDateTimeInUtc
is set totrue
.Current Behavior
The DynamoDB SDK converts
DateTime?
saved in the table as UTC to Local time upon retrieval whenDynamoDBContextConfig.RetrieveDateTimeInUtc
is set totrue
.Reproduction Steps
Prerequisites:
users
.Possible Solution
File: src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs, Line: 470
Existing code:
Replace to something like this:
Additional Information/Context
From
csproj
:AWS .NET SDK and/or Package version used
AWSSDK.DynamoDBv2 3.7.303.16
Targeted .NET Platform
.NET 8
Operating System and version
Windows 10
The text was updated successfully, but these errors were encountered: