开发者

(Asp.net) I can't Insert a new row using Linq to Sql

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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜