Ejemplo n.º 1
0
        private async Task CreateTableForum()
        {
            string tableName = "Forum";

            var response = await _client.CreateTableAsync(new CreateTableRequest
            {
                TableName            = tableName,
                AttributeDefinitions = new List <AttributeDefinition>()
                {
                    new AttributeDefinition
                    {
                        AttributeName = "Name",
                        AttributeType = "S"
                    }
                },
                KeySchema = new List <KeySchemaElement>()
                {
                    new KeySchemaElement
                    {
                        AttributeName = "Name", // forum Title
                        KeyType       = "HASH"
                    }
                },
                ProvisionedThroughput = new ProvisionedThroughput
                {
                    ReadCapacityUnits  = 10,
                    WriteCapacityUnits = 5
                }
            });

            await TableTools.WaitTillTableCreated(_client, tableName, response);
        }
Ejemplo n.º 2
0
        public async Task Run()
        {
            var clientConfig = new AmazonDynamoDBConfig {
                ServiceURL = "http://localhost:8000"
            };

            _client = new AmazonDynamoDBClient(clientConfig);

            try
            {
                // DeleteAllTables(client);
                await TableTools.DeleteTable(_client, "ProductCatalog");

                await TableTools.DeleteTable(_client, "Forum");

                await TableTools.DeleteTable(_client, "Thread");

                await TableTools.DeleteTable(_client, "Reply");

                // Create tables (using the AWS SDK for .NET low-level API).
                await CreateTableProductCatalog();
                await CreateTableForum();
                await CreateTableThread(); // ForumTitle, Subject */
                await CreateTableReply();

                // Load data (using the .NET SDK document API)
                await LoadSampleProducts();
                await LoadSampleForums();
                await LoadSampleThreads();
                await LoadSampleReplies();

                Console.WriteLine("Sample complete!");
                Console.WriteLine("Press ENTER to continue");
                Console.ReadLine();
            }
            catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
            catch (Exception e) { Console.WriteLine(e.Message); }
        }
Ejemplo n.º 3
0
        private async Task CreateTableReply()
        {
            string tableName = "Reply";
            var    response  = await _client.CreateTableAsync(new CreateTableRequest
            {
                TableName            = tableName,
                AttributeDefinitions = new List <AttributeDefinition>()
                {
                    new AttributeDefinition
                    {
                        AttributeName = "Id",
                        AttributeType = "S"
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "ReplyDateTime",
                        AttributeType = "S"
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "PostedBy",
                        AttributeType = "S"
                    }
                },
                KeySchema = new List <KeySchemaElement>()
                {
                    new KeySchemaElement()
                    {
                        AttributeName = "Id",
                        KeyType       = "HASH"
                    },
                    new KeySchemaElement()
                    {
                        AttributeName = "ReplyDateTime",
                        KeyType       = "RANGE"
                    }
                },
                LocalSecondaryIndexes = new List <LocalSecondaryIndex>()
                {
                    new LocalSecondaryIndex()
                    {
                        IndexName = "PostedBy_index",


                        KeySchema = new List <KeySchemaElement>()
                        {
                            new KeySchemaElement()
                            {
                                AttributeName = "Id", KeyType = "HASH"
                            },
                            new KeySchemaElement()
                            {
                                AttributeName = "PostedBy", KeyType = "RANGE"
                            }
                        },
                        Projection = new Projection()
                        {
                            ProjectionType = ProjectionType.KEYS_ONLY
                        }
                    }
                },
                ProvisionedThroughput = new ProvisionedThroughput
                {
                    ReadCapacityUnits  = 10,
                    WriteCapacityUnits = 5
                }
            });

            await TableTools.WaitTillTableCreated(_client, tableName, response);
        }