Somebody just asked me today about the differences between LINQ 2 SQL, TSQL and CLR. I thought I’d post my short answer as it might be useful for other people.
Language Integrated Query, or LINQ is an application-oriented database query language, for example:
var q =
from c in db.Customers
where c.City == “London”
SQL is a row-oriented database query language, for example:
select * from Customers where City = ‘London’
TSQL is the Microsoft version of SQL, PL/SQL is the Oracle version, NZSQL is the Netezza version.
LINQ is good for application-database integration, but the problem is: databases accept SQL language, they don’t accept LINQ.
LINQ 2 SQL is a tool where developer can write LINQ in their application, and this tool will translate it into SQL automatically so that the database can accept it. The output from the database (rows) is then translated back to LINQ Objects.
A Stored Procedure is a collection of SQL queries e.g. TSQL, PL/SQL, NZSQL.
CLR is a way of writing Stored Procedure using application-oriented languages such as C#, C++ and VB.