Skip to content

Instantly share code, notes, and snippets.

@AdamCaviness
Created January 20, 2014 21:17
Show Gist options
  • Save AdamCaviness/8529395 to your computer and use it in GitHub Desktop.
Save AdamCaviness/8529395 to your computer and use it in GitHub Desktop.
var existingSetting = _settings.Where(s => s.SettingKey == setting.SettingKey).FirstOrDefault();
if (existingSetting == null)
throw new ArgumentException("Attempting to update Setting with name '{0}' but the setting is not cached and cannot be updated.");
existingSetting.Value = setting.Value;
var parameters = new UriOperationParameter[] {
new UriOperationParameter("userId", _userSession.User.UserID ),
new UriOperationParameter("serializedSetting", _serializationService.SerializeAsString<Setting>(existingSetting)) };
var context = _dataContextFactory.Create(MergeOption.AppendOnly);
// Perform WCF Data Services ServiceOperation call.
context.Execute<string>(new Uri("UpdateSetting", UriKind.Relative), "POST", true, parameters);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment