コード例 #1
0
 public void DeletePost(PostThread post)
 {
     using (ForumDBContext dc = conn.GetContext())
     {
         dc.PostThreads.DeleteObject(dc.PostThreads.Where
                                         (ac => ac.PostID.Equals(post.PostID)).FirstOrDefault());
         dc.SaveChanges();
     }
 }
コード例 #2
0
 public void DeleteComment(Comment comment)
 {
     using (ForumDBContext dc = conn.GetContext())
     {
         dc.Comments.DeleteObject(dc.Comments.Where
                                      (ac => ac.CommentID.Equals(comment.CommentID)).FirstOrDefault());
         dc.SaveChanges();
     }
 }
コード例 #3
0
        public PostThread SavePost(PostThread post)
        {
            using (ForumDBContext dc = conn.GetContext())
            {
                if (post.PostID > 0)
                {
                    dc.PostThreads.Attach(new PostThread {
                        PostID = post.PostID
                    });
                    dc.PostThreads.ApplyCurrentValues(post);
                }
                else
                {
                    dc.PostThreads.AddObject(post);
                }
                dc.SaveChanges();
            }

            return(post);
        }
コード例 #4
0
        public Comment SaveComment(Comment comment)
        {
            using (ForumDBContext dc = conn.GetContext())
            {
                if (comment.CommentID > 0)
                {
                    dc.Comments.Attach(new Comment {
                        CommentID = comment.CommentID
                    });
                    dc.Comments.ApplyCurrentValues(comment);
                }
                else
                {
                    dc.Comments.AddObject(comment);
                }
                dc.SaveChanges();
            }

            return(comment);
        }