简体   繁体   English

如何使用.NET SDK将List或Map类型推入DynamoDB?

[英]How do I push List or Map type to DynamoDB with the .NET SDK?

I'm trying to push some data into an DynamoDB table and I'm having trouble making the .NET SDK detect that I want a List or Map type, rather than the Numbered/String Set types. 我正在尝试将一些数据推送到DynamoDB表中,但无法使.NET SDK检测到我想要列表或映射类型,而不是编号/字符串集类型。

 var doc = new Document();
 doc["Game ID"] = "SW Proto";
 doc["Run ID"] = 666;
 doc["Profiler Column"] = stats.Key.ToString();
 //doc["Stats Data"] = stats.Value as List<string>;
 // Works:
 doc["Stats Data"] = new List<string> { "2.45", "2.35", "2.5" };
 // Fails:
 doc["Stats Data"] = new List<string> { "2.45", "2.45", "2.45" };

It fails because the data is non-unique, as required for a Set type. 它失败,因为数据是Set类型所需的非唯一数据。

How does one force the data to serialize to List or Map? 如何迫使数据序列化到List或Map?

To store a list (L) instead of a string set (SS), you need to use a different conversion schema. 要存储列表(L)而不是字符串集(SS),您需要使用其他转换模式。 This blog post discusses the different conversion schemas and how they can be used. 这篇博客文章讨论了不同的转换模式以及如何使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM