Пример #1
0
        public async Task ExecuteUpdateStatement(string sql)
        {
            var tokens      = _updateLexicalTokenizer.Tokenize(sql);
            var model       = (UpdateModel)_updateParser.ParseTokens(tokens);
            var updatedKeys = await _queryEngine.GetEntityKeys(model.EntityName, model.WhereCondition);

            foreach (var key in updatedKeys)
            {
                var entityStoreKey = Helpers.GetEntityStoreKey(model.EntityName, key);
                var encodedEntity  = await _stringClient.GetValue(entityStoreKey);

                var entity = JsonConvert.DeserializeObject <dynamic>(encodedEntity);
                await UpdateWeakEntity(entity, model.UpdatedProperties, model.EntityName, key);
            }
        }
Пример #2
0
        private async Task DeleteEntityByKey(string entityName, string key)
        {
            var entityStoreKey = Helpers.GetEntityStoreKey(entityName, key);

            var encodedEntity = await _stringClient.GetValue(entityStoreKey);

            var entity = JsonConvert.DeserializeObject <dynamic>(encodedEntity);

            await _stringClient.DeleteValue(entityStoreKey);

            await _stringClient.DecrementValue(Helpers.GetEntityCountKey(entityName));

            await _setClient.RemoveFromSetByValue(Helpers.GetEntityIdentifierCollectionKey(entityName), key);

            foreach (var property in entity)
            {
                var name             = property.Name;
                var propertyTypeName = await _hashClient.GetHashField(Helpers.GetEntityPropertyTypesKey(entityName), name);

                var value = (property as IEnumerable <dynamic>)?.FirstOrDefault()?.Value?.ToString();
                await PurgeProperty(entityName, key, name, value, propertyTypeName);
            }
        }
Пример #3
0
 private async Task <string> RetrieveEntityJsonByKey(string entityName, string key)
 {
     return(await _stringClient.GetValue(Helpers.GetEntityStoreKey(entityName, key)));
 }