With LINQ to SQL in a ASP.NET MVC website I can display objects (records) from my database table.
Now I would like to create a new object and save it back to the database.
In my Controller, I do this:
var dataContext = new MessageDataContext();
Message message = new Message();
message.Action = "save";
message.Body = "record";
message.Parameter = "234";
And now I want to SAVE it with something like this:
message.Save();
Or perhaps:
dataContext.SubmitChanges(message);
But neither of these work.
What is the syntax here to:
- add new objects and save them to the database?
- make changes on existing objects and save them to the database?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…