Inheritance: DbContext
コード例 #1
0
 public DBBL()
 {
     context = new DBEntities();
     context.Database.Connection.Open();
 }
コード例 #2
0
        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;
        }