0

I am following what I understand is the correct way to do object mapping when pulling from the DynamoDB Database. My issues are that when I do the DyanmoDBContext.Scan function it throws the following exception(as seen below)

Exception thrown: 'System.InvalidOperationException' in AWSSDK.DynamoDBv2.dll

which shows up as

Unable to find storage information for property [BuildingRoutes]

I am failing to understand what is causing this exception to be thrown and thus not actually converting to my custom class.

Below is the main function.

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(); }
    }

Below is the custom class that I am using to scan the database.

 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;

    }


}

Last block of code is the class that I am trying to convert and load the data from the scan into

    [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; }


}

Last block of text is the sample output that I am using for the text to give you guys an idea of what information i am trying to store.

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]
Felcannon
  • 25
  • 4

1 Answers1

0

You're already setting the table to scan with the [DynamoDBTable("BuildingRoutes")] attribute. You're getting an error because you are then trying to scan for the property "BuildingRoutes" inside your table, which doesn't have a BuildingRoutes property.

In short, just remove the following line:

new ScanCondition("BuildingRoutes", ScanOperator.Equal, tableName)

(Your tableName parameter is also unnecessary!)

Mars
  • 2,505
  • 17
  • 26