我按照我的理解是从 DynamoDB 数据库中提取对象时进行对象映射的正确方法。我的问题是,当我执行 DyanmoDBContext.Scan 函数时,它会抛出以下异常(如下所示)抛出异常:AWSSDK.DynamoDBv2.dll 中的“System.InvalidOperationException”显示为找不到属性 [BuildingRoutes] 的存储信息我无法理解是什么导致抛出此异常,因此实际上并未转换为我的自定义类。下面是主要功能。class Program{ static void Main(string[] args) { // Initialize the Amazon Cognito credentials provider CognitoAWSCredentials credentials = new CognitoAWSCredentials( //Not showing my credentials for AWS. ); var client = new AmazonDynamoDBClient(credentials, RegionEndpoint.USEast1); DynamoDBContext context = new DynamoDBContext(client); try { // Query a specific forum and thread. string tableName = "BuildingRoutes"; string primaryKey = "Witmer Hall"; LowLevelQuery.Scan(tableName, primaryKey); List<RoomsObject> building = new List<RoomsObject>(); Console.WriteLine("\n"); IEnumerable<BuildingRoutes> BuildingRoutess = LowLevelQuery.contextScan(tableName, primaryKey); printBuilding(building); Console.WriteLine("Example complete. To continue, press Enter"); Console.ReadLine(); } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); Console.ReadLine(); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); } }
1 回答
12345678_0001
TA贡献1802条经验 获得超5个赞
您已经将表设置为使用[DynamoDBTable("BuildingRoutes")]
属性进行扫描。您收到错误是因为您随后尝试扫描表内的属性“BuildingRoutes”,该表没有 BuildingRoutes 属性。
简而言之,只需删除以下行:
new ScanCondition("BuildingRoutes", ScanOperator.Equal, tableName)
(您的 tableName 参数也是不必要的!)
- 1 回答
- 0 关注
- 88 浏览
添加回答
举报
0/150
提交
取消