By default LINQ to SQL will automatically
create the appropriate SQL expressions for you when you insert/update/delete
entities. For example, if you wrote the LINQ to SQL code below to update
some values on a "Product" entity instance:
Figure 13
By default LINQ to SQL would create and
execute the appropriate "UPDATE" statement for you when you submitted
the changes (I'll cover this more in a later blog post on updates).
You can also optionally define and use custom
INSERT, UPDATE, DELETE sprocs instead. To configure these, just click on
an entity class in the LINQ to SQL designer and within its
property-grid click the "..." button on the Delete/Insert/Update
values, and pick a particular SPROC you've defined instead:
Figure 14
What is nice about changing the above setting is that it is
done purely at the mapping layer of LINQ to SQL - which means the update code I
showed earlier continues to work with no modifications required. This
avoids developers using a LINQ to SQL data model from having to
change code even if they later decide to put in a custom SPROC
optimization later.