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); }
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))); }
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); }
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); } }
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);