コード例 #1
0
        /// <summary>
        /// Create a new PostThread object.
        /// </summary>
        /// <param name="postID">Initial value of the PostID property.</param>
        public static PostThread CreatePostThread(global::System.Int32 postID)
        {
            PostThread postThread = new PostThread();

            postThread.PostID = postID;
            return(postThread);
        }
コード例 #2
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();
     }
 }
コード例 #3
0
        public PostThread GetPostByID(int PostID)
        {
            PostThread post = null;

            using (ForumDBContext dc = conn.GetContext())
            {
                post = (from a in dc.PostThreads where a.PostID == PostID select a).FirstOrDefault();
            }
            return(post);
        }
コード例 #4
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);
        }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the PostThreads EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPostThreads(PostThread postThread)
 {
     base.AddObject("PostThreads", postThread);
 }