In the next chapter you will learn how to delete a single entity in the disconnected mode.
will wrap up all of the changes you have made to the database and submit them as a single transaction, this is good news because if any of them changes fail, they all fail. When linking two records together, you have two choices, both of which I have given an example of.
If you know the keys involved in the relationship you can explicitly set the Foreign Key field eg .
First we will look at a complicated , adding a new customer to the Adventure Works database.
Note: This is not a very good example from the standpoint of keeping the Adventure Works database clean and correct, we are only interested in meeting each of the SQL Constraints, not the business logic. Creating a new record keeps with the mind set of working with objects, so you simply create a new object of the appropriate record type and set its properties.
Update statements are even simpler, again keeping with the mindset of working with objects we simply get an object representing a row, changes it properties and save it back.
Or, if you use Code-First or Model-First approach, then create entities and context classes.
Ive populated the details view using linq and edit mode as default, but Im not sure how to update and changes made to the data.
[...] if you really want to understand something, the best way is to try and explain it to someone else. And the more slow and dim-witted your pupil, the more you have to break things down into more and more simple ideas. By the time you've sorted out a complicated idea into little steps that even a stupid machine can deal with, you've learned something about it yourself.
However, you do not always know the key, especially if the record has just been created, so you can actually link two objects together and LINQ-to-SQL will work out the keys for you.