protected override void DeleteResourceTyped(Guid key) { using (var model = new ResourcesModelContainer()) { DeleteNoSave(key, model, typeof(T)); model.SaveChanges(); } }
protected override void WriteResourceTyped(Guid key, T resource) { Debug.Assert(resource is BaseEntity); using (var model = new ResourcesModelContainer()) { WriteNotSave(key, resource, model, typeof(T)); model.SaveChanges(); } }
private void WriteSeria(IEnumerable <Tuple <UnactualResourceContent, object> > objects) { using (var model = new ResourcesModelContainer()) { foreach (var objs in objects.GroupBy(k => k.Item1.ResourceName)) { var type = _pool.GetTypeByName(objs.Key); foreach (var writingObject in objs) { var key = writingObject.Item1.ResourceKey; if (writingObject.Item2 == null) { DeleteNoSave(key, model, type); } else { WriteNotSave(key, writingObject.Item2, model, type); } } } model.SaveChanges(); } }
public static void SetValue(string category, string section, string key, object value) { var db = new ResourcesModelContainer(); db.Settings.MergeOption = System.Data.Objects.MergeOption.OverwriteChanges; var item = db.Settings.FirstOrDefault(x => x.CultureCode == "en" & x.Category == category & x.Section == section & x.KeyName == key); if (item == null) { item = new Setting(); item.Category = category; item.Section = section; item.KeyName = key; db.Settings.AddObject(item); } item.KeyValue = value.ToString(); if (value == null) { item.KeyType = ""; } else { item.KeyType = value.GetType().Name; } db.SaveChanges(); }