.net 什么是;找不到属性“的存储信息”;使用DynamoDB是什么意思?
我正在使用AWS DynamoDB的.NET SDK运行扫描。我正在这样做:.net 什么是;找不到属性“的存储信息”;使用DynamoDB是什么意思?,.net,amazon-web-services,amazon-dynamodb,.net,Amazon Web Services,Amazon Dynamodb,我正在使用AWS DynamoDB的.NET SDK运行扫描。我正在这样做: var result = context.Scan<Table>(new[] { new ScanCondition("AttributeName", ScanOperator.Equal, variable) } var result=context.Scan(新[]{new ScanCondition(“AttributeName”,ScanOperator.Equal,variable)} 这会引
var result = context.Scan<Table>(new[] { new ScanCondition("AttributeName", ScanOperator.Equal, variable) }
var result=context.Scan(新[]{new ScanCondition(“AttributeName”,ScanOperator.Equal,variable)}
这会引发异常
“找不到属性[AttributeName]的存储信息”
属性AttributeName
是一个未编制索引的属性,目前在其中几乎没有任何值(这是我最近添加的一个新属性)
我在谷歌上搜索了这个错误&我只找到了,我可以深入研究一下,如果没有人能告诉我的话,我会的。DynamoDBContext.Scan()方法只接受使用
[DynamoDBTable()]映射到该表的类T
的公共属性的名称
attribute.Scan
将无法识别表中未映射的属性
如果类T
没有该名称的public属性,或者该属性被显式标记为[DynamoDBIgnore]
,则将引发该异常
如果需要扫描表中未建模的表属性,可以使用AmazondynamodClient.scan()提供的低级API,但它不会返回t类型的对象。您的语句是:
var result = context.Scan<Table>(new[] { new ScanCondition("AttributeName", ScanOperator.Equal, variable) }
参考:这也吸引了我,分享我的发现,希望它能帮助别人,我正在使用C#Object持久化模型 DynamoDb中的列名是驼峰式的,而C#类属性则不是
[DynamoDBProperty("artist")]
[DynamoDBHashKey]
public string Artist { get; set; }
[DynamoDBProperty("songTitle")]
[DynamoDBRangeKey]
public string SongTitle { get; set; }
因此下面抛出错误
scanConditions.Add(new ScanCondition("songTitle", ScanOperator.BeginsWith, searchReq.SongTitle));
if (!string.IsNullOrEmpty(searchReq.Difficulty))
要解决
scanConditions.Add(new ScanCondition("SongTitle", ScanOperator.BeginsWith, searchReq.SongTitle));
if (!string.IsNullOrEmpty(searchReq.Difficulty))
该属性是建模的。它只是没有太多数据。我有一个隐秘的怀疑,这是问题所在,因为低级API可以很好地扫描它。我认为高级API期望数据错误是由检查模型的代码引起的,而不是数据,因此如果它是由数据的某些属性。是否可能模型类已过期soemhow?它是否位于其他DLL中?项目需要在VS中进行清理/重建?不,所有内容都是最新的。尝试了清理,但仍然不起作用。能否提供您正在使用的模型类的完整代码?
scanConditions.Add(new ScanCondition("SongTitle", ScanOperator.BeginsWith, searchReq.SongTitle));
if (!string.IsNullOrEmpty(searchReq.Difficulty))