找不到 属性 [TableName] 的存储信息
Unable to find storage information for property [TableName]
我按照我的理解是从 DynamoDB 数据库中提取对象时进行对象映射的正确方法。我的问题是,当我执行 DyanmoDBContext.Scan 函数时,它抛出以下异常(如下所示)
Exception thrown: 'System.InvalidOperationException' in AWSSDK.DynamoDBv2.dll
显示为
Unable to find storage information for property [BuildingRoutes]
我无法理解是什么导致抛出此异常,因此实际上并未转换为我的自定义 class。
下面是主要功能
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(); }
}
下面是我用来扫描数据库的自定义 class。
class DatabaseScan
{
private static AmazonDynamoDBClient client = new AmazonDynamoDBClient();
public static void Scan(String tableName, String buildingName)
{
Table ThreadTable = Table.LoadTable(client, tableName);
ScanFilter scanFilter = new ScanFilter();
scanFilter.AddCondition("Building", ScanOperator.Equal, buildingName);
Search search = ThreadTable.Scan(scanFilter);
List<Document> documentList = new List<Document>();
do
{
documentList = search.GetNextSet();
Console.WriteLine("\nBelow are all the Edges that are returned from the scan.");
foreach (var document in documentList)
PrintDocument(document);
} while (!search.IsDone);
}
public static IEnumerable<BuildingRoutes> contextScan(String tableName, String buildingName)
{
DynamoDBContext context = new DynamoDBContext(client);
IEnumerable<BuildingRoutes> BuildingRoutess = context.Scan<BuildingRoutes>(
new ScanCondition("Building", ScanOperator.Equal, buildingName),
new ScanCondition("BuildingRoutes", ScanOperator.Equal, tableName)
);
return BuildingRoutess;
}
}
最后一段代码是 class,我正在尝试将扫描数据转换并加载到
[DynamoDBTable("BuildingRoutes")]
public class BuildingRoutes
{
[DynamoDBHashKey("EdgeNum")]
public int EdgeNum { get; set; }
[DynamoDBProperty("Building")]
public String Building { get; set; }
[DynamoDBProperty("Destination")]
public int Destination { get; set; }
[DynamoDBProperty("Distance")]
public int Distance { get; set; }
[DynamoDBProperty("Origin")]
public int Origin { get; set; }
[DynamoDBProperty("OriginEntrance")]
public Boolean OriginEntrance { get; set; }
[DynamoDBProperty("DestinationEntrance")]
public Boolean DestinationEntrance { get; set; }
[DynamoDBProperty("MaxRangeLatitude")]
public float MaxRangeLatitude { get; set; }
[DynamoDBProperty("MaxRangeLongitude")]
public float MaxRangeLongitude { get; set; }
[DynamoDBProperty("MinRangeLatitude")]
public float MinRangeLatitude { get; set; }
[DynamoDBProperty("MinRangelongitude")]
public float MinRangelongitude { get; set; }
}
最后一段文本是我用于文本的示例输出,让你们了解我要存储的信息。
Below are all the Edges that are returned from the scan.
MaxRangeLatitude - 13.525263
EdgeNum - 2
MaxRangeLongitude - 13.256354
MinRangeLongitude - 13.253648
DestinationEntrance -
Origin - 102
MinRangeLatitude - 13.526
Destination - 103
Building - Witmer Hall
OriginEntrance -
MaxRangeLatitude - 0
EdgeNum - 1
MaxRangeLongitude - 0
MinRangeLongitude - 0
DestinationEntrance -
Origin - 101
MinRangeLatitude - 0
Destination - 102
Building - Witmer Hall
OriginEntrance -
MaxRangeLatitude - 13.525263
EdgeNum - 0
MaxRangeLongitude - 13.256354
MinRangeLongitude - 13.253648
DestinationEntrance -
Origin - 0
MinRangeLatitude - 13.526
Destination - 101
Building - Witmer Hall
OriginEntrance -
Unable to find storage information for property [BuildingRoutes]
您已经将 table 设置为使用 [DynamoDBTable("BuildingRoutes")]
属性进行扫描。您收到错误是因为您随后尝试扫描 table 中的 属性 "BuildingRoutes",它没有 BuildingRoutes 属性.
简而言之,只需删除以下行:
new ScanCondition("BuildingRoutes", ScanOperator.Equal, tableName)
(您的 tableName 参数也没有必要!)
我按照我的理解是从 DynamoDB 数据库中提取对象时进行对象映射的正确方法。我的问题是,当我执行 DyanmoDBContext.Scan 函数时,它抛出以下异常(如下所示)
Exception thrown: 'System.InvalidOperationException' in AWSSDK.DynamoDBv2.dll
显示为
Unable to find storage information for property [BuildingRoutes]
我无法理解是什么导致抛出此异常,因此实际上并未转换为我的自定义 class。
下面是主要功能
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(); }
}
下面是我用来扫描数据库的自定义 class。
class DatabaseScan
{
private static AmazonDynamoDBClient client = new AmazonDynamoDBClient();
public static void Scan(String tableName, String buildingName)
{
Table ThreadTable = Table.LoadTable(client, tableName);
ScanFilter scanFilter = new ScanFilter();
scanFilter.AddCondition("Building", ScanOperator.Equal, buildingName);
Search search = ThreadTable.Scan(scanFilter);
List<Document> documentList = new List<Document>();
do
{
documentList = search.GetNextSet();
Console.WriteLine("\nBelow are all the Edges that are returned from the scan.");
foreach (var document in documentList)
PrintDocument(document);
} while (!search.IsDone);
}
public static IEnumerable<BuildingRoutes> contextScan(String tableName, String buildingName)
{
DynamoDBContext context = new DynamoDBContext(client);
IEnumerable<BuildingRoutes> BuildingRoutess = context.Scan<BuildingRoutes>(
new ScanCondition("Building", ScanOperator.Equal, buildingName),
new ScanCondition("BuildingRoutes", ScanOperator.Equal, tableName)
);
return BuildingRoutess;
}
}
最后一段代码是 class,我正在尝试将扫描数据转换并加载到
[DynamoDBTable("BuildingRoutes")]
public class BuildingRoutes
{
[DynamoDBHashKey("EdgeNum")]
public int EdgeNum { get; set; }
[DynamoDBProperty("Building")]
public String Building { get; set; }
[DynamoDBProperty("Destination")]
public int Destination { get; set; }
[DynamoDBProperty("Distance")]
public int Distance { get; set; }
[DynamoDBProperty("Origin")]
public int Origin { get; set; }
[DynamoDBProperty("OriginEntrance")]
public Boolean OriginEntrance { get; set; }
[DynamoDBProperty("DestinationEntrance")]
public Boolean DestinationEntrance { get; set; }
[DynamoDBProperty("MaxRangeLatitude")]
public float MaxRangeLatitude { get; set; }
[DynamoDBProperty("MaxRangeLongitude")]
public float MaxRangeLongitude { get; set; }
[DynamoDBProperty("MinRangeLatitude")]
public float MinRangeLatitude { get; set; }
[DynamoDBProperty("MinRangelongitude")]
public float MinRangelongitude { get; set; }
}
最后一段文本是我用于文本的示例输出,让你们了解我要存储的信息。
Below are all the Edges that are returned from the scan.
MaxRangeLatitude - 13.525263
EdgeNum - 2
MaxRangeLongitude - 13.256354
MinRangeLongitude - 13.253648
DestinationEntrance -
Origin - 102
MinRangeLatitude - 13.526
Destination - 103
Building - Witmer Hall
OriginEntrance -
MaxRangeLatitude - 0
EdgeNum - 1
MaxRangeLongitude - 0
MinRangeLongitude - 0
DestinationEntrance -
Origin - 101
MinRangeLatitude - 0
Destination - 102
Building - Witmer Hall
OriginEntrance -
MaxRangeLatitude - 13.525263
EdgeNum - 0
MaxRangeLongitude - 13.256354
MinRangeLongitude - 13.253648
DestinationEntrance -
Origin - 0
MinRangeLatitude - 13.526
Destination - 101
Building - Witmer Hall
OriginEntrance -
Unable to find storage information for property [BuildingRoutes]
您已经将 table 设置为使用 [DynamoDBTable("BuildingRoutes")]
属性进行扫描。您收到错误是因为您随后尝试扫描 table 中的 属性 "BuildingRoutes",它没有 BuildingRoutes 属性.
简而言之,只需删除以下行:
new ScanCondition("BuildingRoutes", ScanOperator.Equal, tableName)
(您的 tableName 参数也没有必要!)