public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator <TKey, TValue>() { var query = new TableQuery() .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, DictionaryName)); var entityResolver = DictionaryTableEntityResolver <TKey, TValue> .GetResolver(_settings.Serializer.ValueSerialization); TableContinuationToken token = null; do { var results = Table.ExecuteQuerySegmentedAsync(query, entityResolver, token).Result; foreach (var result in results) { yield return(new KeyValuePair <TKey, TValue>(result.GetKey(_settings.Serializer, _settings.KeySerializer), result.GetValue(_settings.Serializer))); } token = results.ContinuationToken; }while (token != null); }
public async Task <TryGetAsyncResult <TValue> > TryGetValueAsync <TKey, TValue>(TKey key) { await CreateTableIfNotExistsAsync().ConfigureAwait(false); var serializedKey = _settings.KeySerializer.SerializeAsKey(_settings.Serializer, key); var tableOperation = TableOperation.Retrieve(DictionaryName, serializedKey, DictionaryTableEntityResolver <TKey, TValue> .GetResolver(_settings.Serializer.ValueSerialization)); var result = await Table.ExecuteAsync(tableOperation).ConfigureAwait(false); var entity = (IDictionaryTableEntity <TKey, TValue>)result.Result; return((entity == null) ? TryGetAsyncResult <TValue> .NotFound : new TryGetAsyncResult <TValue>(entity.GetValue(_settings.Serializer))); }
public async Task <bool> ContainsKeyAsync <TKey>(TKey key) { await CreateTableIfNotExistsAsync().ConfigureAwait(false); var tableOperation = TableOperation.Retrieve(DictionaryName, _settings.KeySerializer.SerializeAsKey(_settings.Serializer, key), DictionaryTableEntityResolver <TKey, object> .GetResolver(KumoDictionaryValueSerialization.Binary)); var result = await Table.ExecuteAsync(tableOperation).ConfigureAwait(false); var entity = (IDictionaryTableEntity <TKey, object>)result.Result; return(entity != null); }