示例#1
0
        public async Task <InfraVersion> GetInfraVersionAsync(string stage, string infraName)
        {
            // Create a retrieve operation that takes the stage (patition key) and infraName (row).
            var retrieveOperation = TableOperation.Retrieve <InfraVersion>(stage, infraName);
            // Execute the retrieve operation.
            TableResult retrievedResult = await _table.ExecuteAsync(retrieveOperation);

            // value doesn't exist in db
            if (retrievedResult.Result == null)
            {
                // create the row, set version to zero
                var newRowValue = new InfraVersion(stage, infraName);
                newRowValue.Version = 0;
                // add to db
                await AddInfraVersionAsync(newRowValue);

                // set to result so the newly added row will get returned
                retrievedResult.Result = newRowValue;
            }
            return((InfraVersion)retrievedResult.Result);
        }
示例#2
0
 private async Task AddInfraVersionAsync(InfraVersion version)
 {
     var insertOperation = TableOperation.InsertOrMerge(version);
     await _table.ExecuteAsync(insertOperation);
 }