static void UpdateArticle(Article article) { using (var db = new ArticleContext()) { db.Articles.Attach(article); db.Entry(article).State = EntityState.Modified; db.SaveChanges(); } }
static void CreateArticle(Article article) { using (var db = new ArticleContext()) { db.Articles.Add(article); db.SaveChanges(); } }
static void UpdateArticle(Article article) { using (var db = new ArticleContext()) { db.Articles.Attach(article); db.Entry(article).State = EntityState.Modified; db.SaveChanges(); } }
static void DeleteArticle(Article article) { using (var db = new ArticleContext()) { db.Articles.Attach(article); db.Articles.Remove(article); //db.Entry(article).State = EntityState.Deleted; db.SaveChanges(); } }
static void DeleteArticle(Article article) { using (var db = new ArticleContext()) { db.Articles.Attach(article); db.Articles.Remove(article); //db.Entry(article).State = EntityState.Deleted; db.SaveChanges(); } }
static void CreateArticle(Article article) { using (var db = new ArticleContext()) { db.Articles.Add(article); db.SaveChanges(); } }