There are times when you want to add validation logic that
is specific to insert, update or delete scenarios. LINQ to SQL in Beta2
enables this by allowing you to add a partial class to extend your DataContext
class and then implement partial methods to customize the Insert, Update and Delete
logic for your data model entities. These methods will be called
automatically when you invoke SubmitChanges() on your DataContext.
You can add appropriate validation logic within these
methods - and if it passes then tell LINQ to SQL to continue with persisting
the relevant changes to the database (by calling the DataContext's
"ExecuteDynamicXYZ" method):
Figure 15

What is nice about adding the above methods is
that the appropriate ones are automatically invoked regardless of the scenario
logic that caused the data objects to be created/updated/deleted. For
example, consider a simple scenario where we create a new Order and associate
it with an existing Customer:
Figure 16

When we call northwind.SubmitChanges() above, LINQ to SQL
will determine that it needs to persist a new Order object, and our
"InsertOrder" partial method will automatically be invoked.