One of the questions that developers (and especially DBAs)
who are used to writing SPROCs with custom SQL usually ask when seeing LINQ to
SQL for the first time is - "but how can I have complete control of the
underlying SQL that is executed?"
The good news is that LINQ to SQL has a pretty flexible
model that enables developers to override the dynamic SQL that is automatically
executed by LINQ to SQL, and instead call custom insert, update, delete SPROCs
that they (or a DBA) define themselves.
What is really nice is that you can start off by defining
your data model and have LINQ to SQL automatically handle the insert, update,
delete SQL logic for you. You can then at a later point customize the
data model to use your own custom SPROCs or SQL for updates - without having to
change any of the application logic that is using your data model,
nor would you have to change any of the validation or business rules
logic supporting it (all of this stays the same). This provides a lot of
flexibility in how you build your application.
I'll cover how to customize your data models to use SPROCs
or custom SQL in a future blog post.