Beispiel #1
0
        static TableOperation MakeDeleteOperation(Key key, string versionToDelete)
        {
            key = KeyEncode(key);
            var entity = AzureTableEntity.KeyOnly(key);

            entity.ETag = versionToDelete;
            return(TableOperation.Delete(entity));
        }
        public void PropertyNameRoundtrip()
        {
            const string disallowedCharacters = "\\/#?а";
            string       encoded = AzureTableEntity.EncodeKey(disallowedCharacters);
            string       decoded = AzureTableEntity.DecodeKey(encoded);

            Assert.AreEqual(disallowedCharacters, decoded);
        }
Beispiel #3
0
        public Task Put(Key key, Value value)
        {
            CheckKey(key);
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            key = KeyEncode(key);
            var entity = new AzureTableEntity(key, value);

            return(this.table.ExecuteAsync(TableOperation.InsertOrReplace(entity)));
        }
Beispiel #4
0
        static TableOperation MakePutOperation(Key key, Value value, string versionToUpdate)
        {
            key = KeyEncode(key);
            var            entity = new AzureTableEntity(key, value);
            TableOperation operation;

            if (versionToUpdate == null)
            {
                operation = TableOperation.Insert(entity);
            }
            else
            {
                entity.ETag = versionToUpdate;
                operation   = TableOperation.Replace(entity);
            }
            return(operation);
        }
Beispiel #5
0
        public async Task <bool?> Delete(Key key)
        {
            CheckKey(key);

            key = KeyEncode(key);
            var entity = AzureTableEntity.KeyOnly(key);

            try
            {
                await this.table.ExecuteAsync(TableOperation.Delete(entity)).ConfigureAwait(false);

                return(true);
            }
            catch (StorageException e) when(e.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
            {
                return(false);
            }
        }
Beispiel #6
0
 static Dictionary <string, object> ParseValue(DynamicTableEntity result) =>
 result.Properties
 .Where(kv => AzureTableEntity.IsKey(kv.Key))
 .ToDictionary(kv => AzureTableEntity.DecodeKey(kv.Key), kv => kv.Value.PropertyAsObject);