/// <summary> /// 添加或更新键值对信息信息 /// </summary> /// <param name="dtos">要添加的键值对信息DTO信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> CreateOrUpdateKeyValueCouples(params KeyValueCouple[] dtos) { Check.NotNull(dtos, nameof(dtos)); foreach (KeyValueCouple dto in dtos) { KeyValueCouple pair = _keyValueRepository.TrackEntities.FirstOrDefault(m => m.Key == dto.Key); if (pair == null) { pair = dto; await _keyValueRepository.InsertAsync(pair); } else { pair.Value = dto.Value; await _keyValueRepository.UpdateAsync(pair); } } await _cache.RemoveAsync(AllKeyValueCouplesKey); return(OperationResult.Success); }
/// <summary> /// 添加或更新键值对信息信息 /// </summary> /// <param name="key">键</param> /// <param name="value">值</param> /// <returns>业务操作结果</returns> public Task <OperationResult> CreateOrUpdateKeyValueCouple(string key, object value) { KeyValueCouple pair = new KeyValueCouple(key, value); return(CreateOrUpdateKeyValueCouples(pair)); }