...
Supported Operations
Operation | Methods Supported |
---|
CreateCreateTabletitle | Insert Operation Methods |
---|
| - Amazon.DynamoDBv2.DocumentModel.Table.PutItem
|
|
WriteBatchItemUpdate | |
Select | - Query
- Scan
- GetItem
- BatchGetItem
- DescribeTable
|
Delete | DeleteItemDeleteTable- Amazon.DynamoDBv2.DocumentModel.Table.PutItemAsync
- Amazon.DynamoDBv2.DocumentModel.Table.TryPutItem
- Amazon.DynamoDBv2.DataModel.DynamoDBContext.Save
- Amazon.DynamoDBv2.DataModel.DynamoDBContext.SaveAsync
|
|
Update |
Expand |
---|
title | 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 |
Expand |
---|
title | 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 |
Expand |
---|
title | 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
Icon | Description |
---|
| .NET DynamoDB DotNet AWS DynamoDB Client |
| .NET DotNet AWS DynamoDB Table |
| .NET DotNet AWS Unknown DynamoDB Client |
| .NET DotNet AWS Unknown DynamoDB Table Table |
Links
Links are created for transaction and function point needs:
Link type | Source and destination of link | Methods Supported |
---|
parentLink | Between DynamoDB client object and belongsTo | From DotNet AWS DynamoDB Table to DotNet AWS DynamoDB Client object
|
|
useLink | Between the caller .NET Method objects and DynamoDB tables | CreateTable(C#) object and DotNet AWS DynamoDB Table
|
useInsertink | - PutItemBatchWriteItem
- 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?
...
AmazonDynamoDB Client and Table Creation
Expand |
---|
title | AmazonDynamoDB Client and Table creation |
---|
|
Code Block |
---|
language | c# |
---|
title | Client and Table |
---|
|
| Creationpublic partial Programprivatestaticstringtable1 = "BookDatabase";
private static new AmazonDynamoDBConfig();
// Set the endpoint URL
clientConfig.ServiceURL = "http://localhost:8000";
AmazonDynamoDBClient client = new AmazonDynamoDBClient(clientConfig); |
voidCreateTable()
{
ProvisionedThroughput throughput = new ProvisionedThroughput
{
ReadCapacityUnits = 50,
WriteCapacityUnits = 50
};
tableName = "ProductCatalog";
| ConfiguretheCreateTablerequestthe following id PK value to add book item.
| varcreateTableRequest=newCreateTableRequest {
TableName = table1,int sampleBookId = 555;
static void | AttributeDefinitions = new List<AttributeDefinition>()
newAttributeDefinition AttributeName"Author"Table.LoadTable(client, tableName);
CreateBookItem(productCatalog);
| AttributeType="S" RetrieveBook(productCatalog);
| }, // Couple of sample updates.
| newAttributeDefinition UpdateMultipleAttributes(productCatalog);
UpdateBookPriceConditionally(productCatalog);
| {AttributeName="Title", DeleteBook(productCatalog);
| AttributeType = "S"
Console.WriteLine("To continue, press Enter");
| }
,
catch (AmazonDynamoDBException e) | KeySchema = new List<KeySchemaElement>()
{ Console.WriteLine(e.Message); }
catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
catch (Exception e) { Console.WriteLine(e.Message); }
| newKeySchemaElement{ Image Added
|
Insert Operation
Expand |
---|
|
Code Block |
---|
| private static void CreateBookItem(Table productCatalog)
| AttributeName="Author", Console.WriteLine("\n*** Executing | KeyType = "HASH" //Partition keyCreateBookItem() ***");
var | },
new KeySchemaElementbook = new Document();
book["Id"] = sampleBookId;
| { AttributeName = ,] = "Book " + sampleBookId;
| KeyType = "RANGE" //Partition key
}
},
ProvisionedThroughput = throughput
}var response = client.CreateTable(createTableRequest);
book["ISBN"] = "111-1111111111";
| }} |
Image Removed
Insert Data Operation
Code Block |
---|
|
privatestaticvoidInsertData(){ Dictionary<string, AttributeValue> attributes4 = new Dictionary<string, AttributeValue>();
attributes4["AuthorAttributeValueS = "D J Munro"Author 1", "Author 2", "Author 3" };
| attributes4["Title"]=newAttributeValue{S="SlavetoFortune"}; attributes4Yearsnew 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);
} |
Image Removed
Select Operation
Code Block |
---|
|
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); |
Image Removed
Code Block |
---|
|
var scanRequest = new ScanRequest
{
TableName = table1,
ExpressionAttributeValues = new Dictionary<string, AttributeValue> {
{":years", new AttributeValue { N = "2000" }} },
FilterExpression = "Years > :years"
};
var scanResponse = client.Scan(scanRequest); |
Image Removed
Code Block |
---|
|
DescribeTableRequest describeRequest = new DescribeTableRequest
{
TableName = table1
};
var describeResponse = client.DescribeTable(describeRequest).Table; |
Image Removed
Code Block |
---|
|
GetItemRequest getRequest = new GetItemRequest
{
TableName = table1,
Key = keys,
};
GetItemResponse r = client.GetItem(getRequest); |
Image Removed
...
500;
book["Dimensions"] = "8.5x11x.5";
book["InPublication"] = new DynamoDBBool(true);
book["InStock"] = new DynamoDBBool(false);
book["QuantityOnHand"] = 0;
productCatalog.PutItem(book);
} |
Image Added
|
Select Operation
Expand |
---|
|
var |
title | Update |
---|
updateRequest=newUpdateTableRequest
{
TableName = table1,RetrieveBook(Table productCatalog)
{
| ProvisionedThroughput=newProvisionedThroughput() Console.WriteLine("\n*** Executing | {
// Provide new values.RetrieveBook() ***");
// Optional configuration.
| ReadCapacityUnits=100, GetItemOperationConfig config = new GetItemOperationConfig
| WriteCapacityUnits=100 }
};varupdateResponse=client.UpdateTable(updateRequest); |
Image Removed
Code Block |
---|
language | c# |
---|
title | UpdateItem |
---|
|
UpdateItemRequest updateRequestUpdateItemRequest
TableName = table1,
Key = keys,
AttributeUpdates = updates
};
clientUpdate.UpdateItem(updateRequest); |
Image Removed
Delete Operation
Code Block |
---|
|
var deleteRequest = new DeleteTableRequest
{
TableName = table1
};
var responseDelete = clientDelete.DeleteTable(deleteRequest); |
Image Removed
Code Block |
---|
language | c# |
---|
title | DeleteItem |
---|
|
DeleteItemRequest deleteRequest = new DeleteItemRequest
{
TableName = table1,
Key = keys
};client.DeleteItem(deleteRequest); |
Image Removed
Batch Operations
Code Block |
---|
language | c# |
---|
title | BatchWriteItem |
---|
|
BatchWriteItemRequest request = new BatchWriteItemRequest
{
RequestItems = new Dictionary<string, List<WriteRequest>>
"Id", "ISBN", "Title", "Authors", "Price" },
ConsistentRead = true
};
Document document = productCatalog.GetItem(sampleBookId, config);
| { { table1, sampleTableItems1 },Console.WriteLine("RetrieveBook: Printing book retrieved...");
PrintDocument(document);
| { "StudentDatabase",sampleTableItems2 }
}
};
BatchWriteItemResponse response = client.BatchWriteItem(request); |
...
Image Added
|
Update Operation
Expand |
---|
|
var request = new BatchGetItemRequest
{
RequestItems = new Dictionary<string, KeysAndAttributes>( |
title | BatchReadItem |
---|
private static void UpdateBookPriceConditionally(Table productCatalog)
{
| { Console.WriteLine("\n*** Executing UpdateBookPriceConditionally() ***");
| table1,sampleTableItems2 int partitionKey = sampleBookId;
| }, var book = new Document();
| { book["Id"] = partitionKey;
| "StudentDatabase", new KeysAndAttributesbook["Price"] = 29.99;
// For conditional price update, creating a condition expression.
| { KeysList<Dictionary<string, AttributeValue> >Expression();
expr.ExpressionStatement = "Price = :val";
| {
expr.ExpressionAttributeValues[":val"] = 19.00;
// Optional parameters.
UpdateItemOperationConfig | newDictionary<string, AttributeValue>()
= new UpdateItemOperationConfig
{
ConditionalExpression = expr,
| { "RollNo", new AttributeValue { N = "67" } }ReturnValues = ReturnValues.AllNewAttributes
};
Document updatedBook | },
= productCatalog.UpdateItem(book, config);
Console.WriteLine("UpdateBookPriceConditionally: Printing item whose price was conditionally updated");
| newDictionary<string, AttributeValue>PrintDocument(updatedBook);
} |
Image Added
|
Delete Operation
Expand |
---|
|
Code Block |
---|
| private static void DeleteBook(Table productCatalog)
{
| { Console.WriteLine("\n*** Executing DeleteBook() ***");
// Optional configuration.
DeleteItemOperationConfig config | { "RollNo", AttributeValueDeleteItemOperationConfig
| {N="1310"}} {
// Return the deleted item.
| } ReturnValues.AllOldAttributes
| };
Document document = productCatalog.DeleteItem(sampleBookId, config);
| } Console.WriteLine("DeleteBook: Printing deleted just deleted...");
| }};
response = client.BatchGetItem(request); |
...
Image Added
|
Evolution
- Previously, only files consisting of relevant DynamoDB imports were processed further for analysing.
- Support has been evolved to process a file when it does not contain DynamoDB import but makes use of its methods (APIs). Assumption here is file makes use of same namespace as used in the file containing DynamoDB imports.
Limitations
- Client and table names are resolved as known tables only in the following situations:
- Name is hardcoded
- Name is defined in the variable in the local method
- Name is defined as C# field
The AWS SDK For .Net provides three models for communicating with DynamoDB:
Communication Model | Namespace | Support |
---|
Low-level | Amazon.DynamoDBv2 | Yes |
Document | Amazon.DynamoDBv2.DocumentModel | No |
Object Persistence | Resolution for table objects and crud links are increased- New support for Communication Models 'Amazon.DynamoDBv2.DocumentModel' and 'Amazon.DynamoDBv2.DataModel'
No |
Future development
...
Limitations
- Client objects are always default with the name 'client'
- If the client and table are not resolved will create Unknown Objects.