public DBBL() { context = new DBEntities(); context.Database.Connection.Open(); }
public Article EditWiki(Article a) { context.Database.ExecuteSqlCommand("EXEC dbo.DeleteTagInCategory " + a.ArticlesID); context.Database.ExecuteSqlCommand("EXEC dbo.DeleteTagInArticles " + a.ArticlesID); foreach (var cat in a.Categories.ToList()) { context.Database.ExecuteSqlCommand("EXEC [dbo].[usp_ArticlesInCategoryInsert] "+a.ArticlesID+","+cat.CategoryID); } foreach (var tag in a.Tags.ToList()) { context.Database.ExecuteSqlCommand("EXEC [dbo].[usp_TagInArticleInsert] "+a.ArticlesID+","+tag.TagID); } context = new DBEntities(); Article b = context.Articles.Where(x => x.ArticlesID == a.ArticlesID).SingleOrDefault(); b = a; context.SaveChanges(); return b; }