DynamoDB将属性值转换为类型
是否有更有效的方法将Dynamo DB数据转换为具体类型?例如,当我查询数据时,所有内容都在:
List<Dictionary<string, AttributeValue>>
是否可以轻松地转换该类型而无需循环遍历每个项目并手动执行此操作?
例如,我正在做:
return items.Select(item => new Connection
{
ConnectionId = Guid.Parse(item["connectionId"].S),
ClientId = item["clientId"].S,
ProviderId = item["providerId"].S,
Scopes = item["scopes"].SS.ToArray(),
CredentialsId = item["credentialsId"].S,
Evidences = ToEvidences(item["consentEvidences"].L)
})
.ToList();
然后返回我的类型连接
的列表,但是我明确映射了每个字段。是否有一个更简单的方法或辅助库可以进行映射?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现的最简单方法是使用
document.fromttributemap
函数将其转换为document
对象,然后使用再次将其转换为.NET类型DynamodBcontext.fromDocument
方法如下所示。The easiest way I have found is to use the
Document.FromAttributeMap
function to convert it to aDocument
object and then convert it again to the .NET type using theDynamoDBContext.FromDocument
method as shown below.我认为您会使用高级.NET文档模型运气。它显示了更多自然数据类型。
I think you'll have luck with the higher-level .NET Document model. It presents more natural data types.
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DotNetSDKMidLevel.html