IDynamoDBContext.ToDocument ignores read-only properties
- Dominant language
- C#
- Stars
- 140
- Forks
- 891
- Avg merge
- 21h 51m
- Merged PRs (30d)
- 10
Description
## Description
Read-only POCO properties are ignored when creating a `Document` using [`IDynamoDBContext.ToDocument`](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/DynamoDBv2/MIDynamoDBContextToDocumentTDynamoDBOperationConfig.html)
These properties have values and should be included in the produced `Document`.
## Reproduction Steps
Create a POCO with DynamoDB annotations and a read-only property (`Greeting`)
``` c#
public class MyObject
{
[DynamoDBHashKey("id")]
public string Id { get; set; }
[DynamoDBProperty("name")]
public string Name { get; set; }
[DynamoDBProperty("greeting")]
public string Greeting => $"Hello, {Name}"
}
```
Create a `Document` and inspect the keys / values
``` c#
var myobj = new MyObject
{
Id = "my-id",
Name = "Phil"
};
Console.WriteLine(myobj.Greeting); // "Hello, Phil"
var context = new DynamoDBContext(ddbclient);
var document = context.ToDocument(myobj);
Console.WriteLine(document.Count); // 2
Console.WriteLine(document.Keys.Contains("id")); // true
Console.WriteLine(document.Keys.Contains("name")); // true
Console.WriteLine(document.Keys.Contains("greeting")); // false
```
### Environment
* SDK Version: AWSSDK.DynamoDBv2 3.3.106.36
* OS Info: Windows 10
* Build Environment: Jetbrains Rider and `dotnet` CLI
* Targeted .NET Platform: .Net Core 3.1
---
This is a :bug: bug-report
Contributor guide
Research direction
Start at the IDynamoDBContext.ToDocument implementation and reproduce the behavior with the MyObject example from the issue. Verify how annotated read-only properties are handled, then confirm that the resulting Document includes the "greeting" key and value alongside "id" and "name".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100