public bool DeleteAppData(string personId, HashSet<string> keys, string appId) { using (var db = new AzureRayaDataContext()) { if (keys.Count == 0) { var ret = db.applicationSettings .Where(x => x.application_id == appId && x.PartitionKey == personId); db.DeleteAllOnSubmit(ret); } else { foreach (var key in keys) { var ret = db.applicationSettings .Where(x => x.application_id == appId && x.PartitionKey == personId && x.name == key); db.DeleteOnSubmit(ret); } } db.SubmitChanges(); } return true; }
public bool SetAppData(string personId, string key, string value, string appId) { string rowKey = string.Concat(personId, "-", appId, "-", key); using (var db = new AzureRayaDataContext()) { if (string.IsNullOrEmpty(value)) { // empty key kind of became to mean "delete data" (was an old orkut hack that became part of the spec spec) var ret = new ApplicationSettingRow(personId, rowKey) { application_id = appId, person_id = personId, name = key }; db.DeleteOnSubmit(ret); } else { var ret = db.applicationSettings .Where(x => x.RowKey == rowKey && x.PartitionKey == personId).SingleOrDefault(); if (ret == null) { ret = new ApplicationSettingRow(personId, rowKey) { application_id = appId, person_id = personId, name = key, value = value }; db.InsertOnSubmit(AzureRayaDataContext.TableNames.applicationSettings, ret); } else { ret.value = value; db.UpdateOnSubmit(ret); } } db.SubmitChanges(); } return true; }