Page tree
Skip to end of metadata
Go to start of metadata

CAST supports DynamoDB via its NoSQL for .NET extension. Details about how this support is provided for .NET source code is discussed below.

Supported Client Libraries

Supported Operations

OperationMethods Supported
Insert
 Insert Operation Methods
  • Amazon.DynamoDBv2.DocumentModel.Table.PutItem
  • Amazon.DynamoDBv2.DocumentModel.Table.PutItemAsync
  • Amazon.DynamoDBv2.DocumentModel.Table.TryPutItem
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.Save
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.SaveAsync
Update
 Update Operation Methods
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.UpdateItem
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.UpdateItemAsync
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.UpdateTable
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.UpdateTableAsync
  • Amazon.DynamoDBv2.IAmazonDynamoDB.UpdateItem
  • Amazon.DynamoDBv2.IAmazonDynamoDB.UpdateItemAsync
  • Amazon.DynamoDBv2.IAmazonDynamoDB.UpdateTable
  • Amazon.DynamoDBv2.IAmazonDynamoDB.UpdateTableAsync
  • Amazon.DynamoDBv2.DocumentModel.Table.UpdateItem
  • Amazon.DynamoDBv2.DocumentModel.Table.UpdateItemAsync
  • Amazon.DynamoDBv2.DocumentModel.Table.TryUpdateItem
Select 
 Select Operation Methods
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.Scan
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.ScanAsync
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.BatchGetItem
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.BatchGetItemAsync
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.BatchWriteItem
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.BatchWriteItemAsync
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.GetItem
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.GetItemAsync
  • Amazon.DynamoDBv2.IAmazonDynamoDB.DescribeTable
  • Amazon.DynamoDBv2.IAmazonDynamoDB.DescribeTableAsync
  • Amazon.DynamoDBv2.IAmazonDynamoDB.BatchGetItem
  • Amazon.DynamoDBv2.IAmazonDynamoDB.BatchGetItemAsync
  • Amazon.DynamoDBv2.IAmazonDynamoDB.Query
  • Amazon.DynamoDBv2.IAmazonDynamoDB.QueryAsync
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.QueryAsync
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.LoadAsync
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.Load
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.Scan
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.ScanAsync
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.FromDocuments
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.FromQuery
  • Amazon.DynamoDBv2.DocumentModel.Table.DescribeTable
  • Amazon.DynamoDBv2.DocumentModel.Table.GetItem
  • Amazon.DynamoDBv2.DocumentModel.Table.GetItemAsync
  • Amazon.DynamoDBv2.DocumentModel.Table.Query
  • Amazon.DynamoDBv2.DocumentModel.Table.Scan
  • Amazon.DynamoDBv2.DocumentModel.Table.TryLoadTable


Delete 
 Delete Operation Methods
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.DeleteItem
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.DeleteItemAsync
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.DeleteTable
  • Amazon.DynamoDBv2.AmazonDynamoDBClient.DeleteTableAsync
  • Amazon.DynamoDBv2.IAmazonDynamoDB.DeleteItem
  • Amazon.DynamoDBv2.IAmazonDynamoDB.DeleteItemAsync
  • Amazon.DynamoDBv2.IAmazonDynamoDB.DeleteTable
  • Amazon.DynamoDBv2.IAmazonDynamoDB.DeleteTableAsync
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.Delete
  • Amazon.DynamoDBv2.DataModel.DynamoDBContext.DeleteAsync
  • Amazon.DynamoDBv2.DocumentModel.Table.DeleteItem
  • Amazon.DynamoDBv2.DocumentModel.Table.DeleteItemAsync
  • Amazon.DynamoDBv2.DocumentModel.Table.TryDeleteItem

Objects

IconDescription

.NET DynamoDB Client

.NET DynamoDB Table

.NET Unknown DynamoDB Client

 

.NET Unknown DynamoDB Table 

Links are created for transaction and function point needs:

Link typeSource and destination of link Methods Supported
parentLink

Between DynamoDB client object and DynamoDB Table




useInsertink

  • PutItem
  • PutItemAsync
  • TryPutItem
  • Save
  • SaveAsync
useUpdateLink
  • UpdateTable
  • UpdateTableAsync
  • UpdateItem
  • UpdateItemAsync
  • TryUpdateItem
useSelectLink
  • Query
  • QueryAsync
  • Scan
  • ScanAsync
  • DescribeTable
  • GetItem
  • GetItemAsync
  • BatchGetItem
  • BatchGetItemAsync
  • BatchWriteItem
  • BatchWriteItemAsync
  • Load
  • LoadAsync
  • FromDocuments
  • FromQuery
  • TryLoadTable
useDeleteLink
  • DeleteItem
  • DeleteItemAsync
  • DeleteTable
  • DeleteTableAsync
  • Delete
  • TryDeleteItem

What results can you expect?

Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten). Some examples are shown below.

AmazonDynamoDB Client and Table Creation

 AmazonDynamoDB Client and Table creation
Client and Table creation
public partial class Program
    {
        private static string table1 = "BookDatabase";
        private static AmazonDynamoDBClient client = new AmazonDynamoDBClient();

        private static void CreateTable()
        {
            ProvisionedThroughput throughput = new ProvisionedThroughput
            {
                ReadCapacityUnits = 50,
                WriteCapacityUnits = 50
            };
            // Configure the CreateTable request
            var createTableRequest = new CreateTableRequest
            {
                TableName = table1,
                AttributeDefinitions = new List<AttributeDefinition>()
                {
                    new AttributeDefinition
                    {
                        AttributeName = "Author",
                        AttributeType = "S"
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "Title",
                        AttributeType = "S"
                    }
                },
                KeySchema = new List<KeySchemaElement>()
                {
                    new KeySchemaElement
                    {
                        AttributeName = "Author",
                        KeyType = "HASH"  //Partition key
                    },
                     new KeySchemaElement
                    {
                        AttributeName = "Title",
                        KeyType = "RANGE"  //Partition key
                    }
                },
                ProvisionedThroughput = throughput
            };
            var response = client.CreateTable(createTableRequest);
        }
}


Insert Operation

 Insert Operation
private static void InsertData()
{            
	    Dictionary<string, AttributeValue> attributes4 = new Dictionary<string, AttributeValue>();
            attributes4["Author"] = new AttributeValue { S = "D J Munro" };
            attributes4["Title"] = new AttributeValue { S = "Slave to Fortune" };
            attributes4["Years"] = new AttributeValue { N = "2015" };
            attributes4["Setting"] = new AttributeValue { S = "Ukraine" };
            attributes4["Pages"] = new AttributeValue { N = "364" };
            attributes4["Genres"] = new AttributeValue { SS = new List<string> { "Emotions" } };


            PutItemRequest insertRequest = new PutItemRequest
            {              
			TableName = table1,
	                Item = attributes1
            };
            client.PutItem(insertRequest);
}

Document model
private static void CreateBookItem(Table productCatalog)
        {
            Console.WriteLine("\n*** Executing CreateBookItem() ***");
            var book = new Document();
            book["Id"] = sampleBookId;
            book["Title"] = "Book " + sampleBookId;
            book["Price"] = 19.99;
            book["ISBN"] = "111-1111111111";
            book["Authors"] = new List<string> { "Author 1", "Author 2", "Author 3" };
            book["PageCount"] = 500;
            book["Dimensions"] = "8.5x11x.5";
            book["InPublication"] = new DynamoDBBool(true);
            book["InStock"] = new DynamoDBBool(false);
            book["QuantityOnHand"] = 0;

            productCatalog.PutItem(book);
        }


Select Operation

 Select Operation
QueryRequest queryRequest = new QueryRequest
{ 
	TableName = table1, 
	KeyConditionExpression = "Author = :Author", 
	ExpressionAttributeValues = new Dictionary<string, AttributeValue> { 
				    { ":Author", new AttributeValue { S = "P G Wodehouse"} } } 
}; 
var queryResponse = client.Query(queryRequest);

var scanRequest = new ScanRequest 
{ 
	TableName = table1, 
	ExpressionAttributeValues = new Dictionary<string, AttributeValue> {
								{":years", new AttributeValue { N = "2000" }} },
	FilterExpression = "Years > :years" 
}; 
var scanResponse = client.Scan(scanRequest);

DescribeTableRequest describeRequest = new DescribeTableRequest 
{ 
	TableName = table1 
}; 
var describeResponse = client.DescribeTable(describeRequest).Table;

GetItemRequest getRequest = new GetItemRequest 
{ 
	TableName = table1, 
	Key = keys, 
}; 
GetItemResponse r = client.GetItem(getRequest);

Document model
 private static void RetrieveBook(Table productCatalog)
        {
            Console.WriteLine("\n*** Executing RetrieveBook() ***");
            // Optional configuration.
            GetItemOperationConfig config = new GetItemOperationConfig
            {
                AttributesToGet = new List<string> { "Id", "ISBN", "Title", "Authors", "Price" },
                ConsistentRead = true
            };
            Document document = productCatalog.GetItem(sampleBookId, config);
            Console.WriteLine("RetrieveBook: Printing book retrieved...");
            PrintDocument(document);
        }


Update Operation

 Update Operation
var updateRequest = new UpdateTableRequest
{
	TableName = table1,
        ProvisionedThroughput = new ProvisionedThroughput()
        {
		// Provide new values.
                ReadCapacityUnits = 100,
                WriteCapacityUnits = 100
         }
};
var updateResponse = client.UpdateTable(updateRequest);  

Document update
 private static void UpdateBookPriceConditionally(Table productCatalog)
        {
            Console.WriteLine("\n*** Executing UpdateBookPriceConditionally() ***");

            int partitionKey = sampleBookId;

            var book = new Document();
            book["Id"] = partitionKey;
            book["Price"] = 29.99;

            // For conditional price update, creating a condition expression.
            Expression expr = new Expression();
            expr.ExpressionStatement = "Price = :val";
            expr.ExpressionAttributeValues[":val"] = 19.00;

            // Optional parameters.
            UpdateItemOperationConfig config = new UpdateItemOperationConfig
            {
                ConditionalExpression = expr,
                ReturnValues = ReturnValues.AllNewAttributes
            };
            Document updatedBook = productCatalog.UpdateItem(book, config);
            Console.WriteLine("UpdateBookPriceConditionally: Printing item whose price was conditionally updated");
            PrintDocument(updatedBook);
        }


Delete Operation

 Delete Operation
DeleteItemRequest deleteRequest = new DeleteItemRequest
{
    TableName = table1,
    Key = keys
};client.DeleteItem(deleteRequest);

document_delete
private static void DeleteBook(Table productCatalog)
        {
            Console.WriteLine("\n*** Executing DeleteBook() ***");
            // Optional configuration.
            DeleteItemOperationConfig config = new DeleteItemOperationConfig
            {
                // Return the deleted item.
                ReturnValues = ReturnValues.AllOldAttributes
            };
            Document document = productCatalog.DeleteItem(sampleBookId, config);
            Console.WriteLine("DeleteBook: Printing deleted just deleted...");
            PrintDocument(document);
        }


Batch Operations

 Batch Operations
BatchWriteItemRequest request = new BatchWriteItemRequest
{
    RequestItems = new Dictionary<string, List<WriteRequest>>
        {        {   table1, sampleTableItems1 },
                {   "StudentDatabase", sampleTableItems2 }
        }
};
BatchWriteItemResponse response = client.BatchWriteItem(request);

var request = new BatchGetItemRequest
{
    RequestItems = new Dictionary<string, KeysAndAttributes>()
        {
        {            table1, sampleTableItems2
                 },
                 { 
                       "StudentDatabase", new KeysAndAttributes
                        {
                            Keys = new List<Dictionary<string, AttributeValue> >()
                            {
                                new Dictionary<string, AttributeValue>()
                                {
                                    { "RollNo", new AttributeValue { N = "67" } }
                                },
                                new Dictionary<string, AttributeValue>()
                                {
                                    { "RollNo", new AttributeValue { N = "1310" } }
                                }
                            }
                        }
                    }
        }
};
response = client.BatchGetItem(request);


Evolution

  • Resolution for table objects and crud links are increased
  • New support for Communication Models 'Amazon.DynamoDBv2.DocumentModel' and 'Amazon.DynamoDBv2.DataModel'

Limitations

  • Client objects are always default with the name 'client'
  • If the client and table are not resolved will create Unknown Objects.


  • No labels