public static void SaveConfig(DynamicConfig config) { Instance = config; using (var db = new ZkDataContext()) { config.Key = 1; db.Entry(config).State = EntityState.Modified; db.SaveChanges(); } }
static DynamicConfig() { using (var db = new ZkDataContext()) { Instance = db.DynamicConfigs.FirstOrDefault(); if (Instance == null) { Instance = new DynamicConfig(); db.DynamicConfigs.Add(Instance); db.SaveChanges(); } } }