示例#1
0
 public bool AddComment()
 {
     using (ModelDesignContainer ctx = new ModelDesignContainer())
     {
         bool bResult = false;
         if (this == null || this.PostPostId == 0)
         {
             return(bResult);
         }
         if (this.CommentId == 0)
         {
             ctx.Entry <Comment>(this).State = System.Data.Entity.EntityState.Added;
             Post p = ctx.Posts.Find(this.PostPostId);
             ctx.Entry <Post>(p).State = System.Data.Entity.EntityState.Unchanged;
             ctx.SaveChanges();
             bResult = true;
         }
         return(bResult);
     }
 }
示例#2
0
 public bool AddPost()
 {
     using (ModelDesignContainer ctx = new ModelDesignContainer())
     {
         bool bResult = false;
         if (this.PostId == 0)
         {
             var it = ctx.Entry <Post>(this).State = System.Data.Entity.EntityState.Added;
             ctx.SaveChanges();
             bResult = true;
         }
         return(bResult);
     }
 }