Example #1
0
        public static Comment AddComment(int postId, string author, string text)
        {
            CSCB766BlogDBEntities blogDB = new CSCB766BlogDBEntities();
            Comment comment = new Comment();

            comment.PostID = postId;
            comment.Author = author;
            comment.CommentText = text;

            blogDB.Comments.AddObject(comment);
            blogDB.SaveChanges();

            return comment;
        }
 /// <summary>
 /// Create a new Comment object.
 /// </summary>
 /// <param name="commentID">Initial value of the CommentID property.</param>
 /// <param name="author">Initial value of the Author property.</param>
 /// <param name="commentText">Initial value of the CommentText property.</param>
 /// <param name="postID">Initial value of the PostID property.</param>
 public static Comment CreateComment(global::System.Int32 commentID, global::System.String author, global::System.String commentText, global::System.Int32 postID)
 {
     Comment comment = new Comment();
     comment.CommentID = commentID;
     comment.Author = author;
     comment.CommentText = commentText;
     comment.PostID = postID;
     return comment;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Comments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToComments(Comment comment)
 {
     base.AddObject("Comments", comment);
 }