Getting A LINQ .InsertOnSubmit To Work
I'm trying to get an insert to work using LINQ and am having some difficulties.
I am using this example to base my code: http://msdn.microsoft.com/en-us/library/bb763516.aspx
I have my data object set up, but don't kno开发者_运维百科w what's going on when db.Orders.InsertOnSubmit is executed.
How can I create this db object to insert a data object into my database using InsertOnSubmit?
edit: Here is some code that I'm working with (It's probably a world of wrong, I'm pretty much fumbling in the dark at this point). I'm super new to database objects, so the whole concept is a bit confusing for me.
var Data = new Data();
Data.value1 = 1;
var db = new dbo(connectionString);
db.InsertOnSubmit(Data);
You need to do more than just call InsertOnSubmit(). You also need to call SubmitChanges()
. The reason these are separate steps is to allow you to have multiple inserts, updates and deletes and then submit them all at once via SubmitChanges().
精彩评论