Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Supported Operations

OperationMethods Supported
Create
Insert


Expand
CreateTable
titleInsert Operation Methods
  • Amazon.DynamoDBv2.DocumentModel.Table.PutItem
  • WriteBatchItem
  • Update
    • UpdateTable
    • UpdateItem
    Select 
    • Query
    • Scan
    • GetItem
    • BatchGetItem
    • DescribeTable
    Delete 
  • DeleteItem
  • DeleteTable
    • Amazon.DynamoDBv2.DocumentModel.Table.PutItemAsync
    • Amazon.DynamoDBv2.DocumentModel.Table.TryPutItem
    • Amazon.DynamoDBv2.DataModel.DynamoDBContext.Save
    • Amazon.DynamoDBv2.DataModel.DynamoDBContext.SaveAsync


    Update


    Expand
    titleUpdate 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
    titleSelect 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
    titleDelete 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 DotNet AWS DynamoDB Client

    .NET DotNet AWS DynamoDB Table

    .NET DotNet AWS Unknown DynamoDB Client

     

    .NET DotNet AWS Unknown DynamoDB Table Table

    Links are created for transaction and function point needs:

    Between DynamoDB client object and  CreateTable
    Link typeSource and destination of link Methods Supported
    parentLink

    belongsTo

    From DotNet AWS DynamoDB Table to DotNet AWS DynamoDB Client object




    useLink

    Between the caller .NET Method

    objects and DynamoDB tables

    (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

    Creation
    Expand
    titleAmazonDynamoDB Client and Table creation


    Code Block
    languagec#
    titleClient and Table
    creation
    public partial
    class 
    Program
    MidlevelItemCRUD
        {
            
    private
    AmazonDynamoDBConfig 
    static
    clientConfig 
    string
    = 
    table1 = "BookDatabase"; private static
    new AmazonDynamoDBConfig();
    		// Set the endpoint URL
    		clientConfig.ServiceURL = "http://localhost:8000";
    		AmazonDynamoDBClient client = new AmazonDynamoDBClient(clientConfig);
    
            private static 
    void
    string 
    CreateTable() { ProvisionedThroughput throughput = new ProvisionedThroughput { ReadCapacityUnits = 50, WriteCapacityUnits = 50 };
    tableName = "ProductCatalog";
            
    // 
    Configure
    The 
    the
    sample 
    CreateTable
    uses 
    request
    the following id PK value to add book item.
        
    var
     
    createTableRequest
     
    =
     
    new
     
    CreateTableRequest
    private static 
    { TableName = table1,
    int sampleBookId = 555;
    
            static void 
    AttributeDefinitions = new List<AttributeDefinition>()
    Main(string[] args)
            
    {
                try
           
    new
     
    AttributeDefinition
        
    {
                    
    AttributeName
    Table productCatalog = 
    "Author"
    Table.LoadTable(client, tableName);
                    CreateBookItem(productCatalog);
          
    AttributeType
     
    =
     
    "S"
            RetrieveBook(productCatalog);
                
    },
        // Couple of sample updates.
                
    new
     
    AttributeDefinition
       UpdateMultipleAttributes(productCatalog);
                    UpdateBookPriceConditionally(productCatalog);
    
    {
    
                    // Delete.
          
    AttributeName
     
    =
     
    "Title",
            DeleteBook(productCatalog);
                    
    AttributeType = "S"
    Console.WriteLine("To continue, press Enter");
                    
    }
    Console.ReadLine();
                
    }
    ,
    
                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); }
    
    new
     
    KeySchemaElement
           }
                 
    {
          
         

    Image Added


    Insert Operation

    Expand
    titleInsert Operation


    Code Block
    languagec#
     private static void CreateBookItem(Table productCatalog)
           
    AttributeName
     
    =
    {
    
    "Author",
                Console.WriteLine("\n*** Executing 
    KeyType = "HASH" //Partition key
    CreateBookItem() ***");
                var 
    }, new KeySchemaElement
    book = new Document();
                book["Id"] = sampleBookId;
         
    {
           
    AttributeName =
    book["Title"
    ,
    ] = "Book " + sampleBookId;
                
    KeyType = "RANGE" //Partition key } }, ProvisionedThroughput = throughput }
    book["Price"] = 19.99;
                
    var response = client.CreateTable(createTableRequest);
    book["ISBN"] = "111-1111111111";
         
    }
     
    }

    Image Removed

    Insert Data Operation

    Code Block
    languagec#
    titlePutItem
    private
     
    static
     
    void
     
    InsertData()
     
    {            
     
    Dictionary<string, AttributeValue> attributes4 = new Dictionary<string, AttributeValue>();             attributes4["Author
     book["Authors"] = new 
    AttributeValue
    List<string> { 
    S = "D J Munro
    "Author 1", "Author 2", "Author 3" };
     
                attributes4["Title"]
     
    =
     
    new
     
    AttributeValue
     
    {
     
    S
     
    =
     
    "Slave
     
    to
     
    Fortune"
     
    };
     
                attributes4
    book["
    Years
    PageCount"] = 
    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); }

    Image Removed

    Select Operation

    Code Block
    languagec#
    titleQuery
    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
    languagec#
    titleScan
    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
    languagec#
    titleDescribe
    DescribeTableRequest describeRequest = new DescribeTableRequest 
    { 
    	TableName = table1 
    }; 
    var describeResponse = client.DescribeTable(describeRequest).Table;

    Image Removed

    Code Block
    languagec#
    titleGetItem
    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
    titleSelect Operation


    var
    Code Block
    languagec#
    titleUpdate
     
    updateRequest
    private 
    =
    static 
    new
    void 
    UpdateTableRequest { TableName = table1,
    RetrieveBook(Table productCatalog)
            {
      
    ProvisionedThroughput
     
    =
     
    new
     
    ProvisionedThroughput()
           Console.WriteLine("\n*** Executing 
    { // Provide new values.
    RetrieveBook() ***");
                // Optional configuration.
        
    ReadCapacityUnits
     
    =
     
    100,
          GetItemOperationConfig config = new GetItemOperationConfig
          
    WriteCapacityUnits
     
    =
     
    100
        {
        
    } };
     
    var
     
    updateResponse
     
    =
     
    client.UpdateTable(updateRequest);
            

    Image Removed

    Code Block
    languagec#
    titleUpdateItem
    UpdateItemRequest updateRequest
    AttributesToGet = new 
    UpdateItemRequest
    List<string> 
    { 
    TableName = table1, Key = keys, AttributeUpdates = updates }; clientUpdate.UpdateItem(updateRequest);

     Image Removed

    Delete Operation

    Code Block
    languagec#
    titleDelete
    var deleteRequest = new DeleteTableRequest
    {
        TableName = table1
    };
    var responseDelete = clientDelete.DeleteTable(deleteRequest);

    Image Removed

    Code Block
    languagec#
    titleDeleteItem
    DeleteItemRequest deleteRequest = new DeleteItemRequest
    {
        TableName = table1,
        Key = keys
    };client.DeleteItem(deleteRequest);

    Image Removed

    Batch Operations

    Code Block
    languagec#
    titleBatchWriteItem
    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
    titleUpdate Operation


    var request = new BatchGetItemRequest { RequestItems = new Dictionary<string, KeysAndAttributes>(
    Code Block
    languagec#
    titleBatchReadItem
    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 KeysAndAttributes
    book["Price"] = 29.99;
    
                // For conditional price update, creating a condition expression.
      
    {
              
    Keys
    Expression expr = new 
    List<Dictionary<string, AttributeValue> >
    Expression();
                expr.ExpressionStatement = "Price = :val";
               
    {
     expr.ExpressionAttributeValues[":val"] = 19.00;
    
                // Optional parameters.
                UpdateItemOperationConfig 
    new
    config 
    Dictionary<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");
               
    new
     
    Dictionary<string, AttributeValue>
    PrintDocument(updatedBook);
            }


    Image Added


    Delete Operation

    Expand
    titleDelete Operation


    Code Block
    languagec#
    private static void DeleteBook(Table productCatalog)
            {
              
    {
      Console.WriteLine("\n*** Executing DeleteBook() ***");
                // Optional configuration.
                DeleteItemOperationConfig config 
    { "RollNo",
    = new 
    AttributeValue
    DeleteItemOperationConfig
    
    {
     
    N
     
    =
     
    "1310"
     
    }
     
    }
           {
                    // Return the deleted item.
        
    }
                ReturnValues = 
    ReturnValues.AllOldAttributes
                
    };
                Document document = productCatalog.DeleteItem(sampleBookId, config);
           
    }
         Console.WriteLine("DeleteBook: Printing deleted just deleted...");
               
    }
     PrintDocument(document);
           
    }
     }
    ; 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 ModelNamespaceSupportLow-levelAmazon.DynamoDBv2YesDocumentAmazon.DynamoDBv2.DocumentModelNoObject PersistenceResolution 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.