开发者

How to insert a new record with LinqToSql?

Googling shows there is to be an "Add" method for this, but there seems to 开发者_开发百科be no Add or anything alike in my LinqToSQL table classes. I've tried "Attach", but with no effect :-(

I use VS2010, .Net 4 and SQL Server 2008 R2.

My tables have no surrogate ID but a natural composite primary key.


yourDatacontext.yourlinqClass.InsertOnSubmit(new yourlinqClass());

yourDatacontext.SubmitChanges();


It's InsertOnSubmit() for LinqToSQL:

ctx.MyClass.InsertOnSubmit(newinstance);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜