public Task RemoveAsync(SettingKey settingKey, SettingGroupKey settingGroupKey, CancellationToken cancellationToken) { return(_msSqlConnection.ExecuteAsync( cancellationToken, DeleteSql, new { Key = settingKey.Value, GroupKey = settingGroupKey.Value })); }
public async Task <string> GetAsync(SettingKey settingKey, SettingGroupKey settingGroupKey, CancellationToken cancellationToken) { var values = await _msSqlConnection.QueryAsync <string>( cancellationToken, GetSql, new { Key = settingKey.Value, GroupKey = settingGroupKey.Value }) .ConfigureAwait(false); return(values.SingleOrDefault()); }
public async Task <IReadOnlyCollection <SettingGroupKey> > GetKeysAsync(SettingGroupKey settingGroupKey, CancellationToken cancellationToken) { var keys = await _msSqlConnection.QueryAsync <string>( cancellationToken, ListSql, new { GroupKey = settingGroupKey.Value }) .ConfigureAwait(false); return(keys .Select(SettingGroupKey.With) .ToList()); }
public async Task SetAsync(SettingKey settingKey, SettingGroupKey settingGroupKey, string value, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException(nameof(value)); } var affectedRows = await _msSqlConnection.ExecuteAsync( cancellationToken, SetSql, new { Key = settingKey.Value, Value = value, GroupKey = settingGroupKey.Value }) .ConfigureAwait(false); if (affectedRows != 1) { throw new Exception($"Updating key '{settingKey}' didn't update any rows"); } }
public static SettingGroupKey ToSettingGroupKey(this PluginId pluginId) { return SettingGroupKey.With($"plugin.{pluginId.Value}"); }