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