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);
精彩评论