So I'm trying to do a simple insert using Linq but i'm running into trouble.
code:
TestDatacontext db = new TestDatacontext ();
Comment com = new Comment();
com.UserID = userId;
com.TaskID = taskId;
com.Description = Server.HtmlEncode(txtComments.Text);开发者_JS百科
com.DateCreated = DateTime.Now;
Now at this point, from what I've read I should be able to do this:
db.Comments.Add(com);
db.Submitchanges();
However, when I write db.Comments
. [There is no Add method]
So...how do I insert?
You're looking for db.Comments.InsertOnSubmit(com);
精彩评论