Pages

Friday, June 27, 2008

What is LINQ?

“Language Integrated Query”

Coming with C# 3.0 and VB.NET 9.0 with native language syntax for queries and provides class libraries to take advantage of these capabilities.

LINQ solves the impedance mismatch between the code that lives on a database server and the code we write with standard programming languages such as C# or VB.

Here are previous problems:
1. Worlds of Object Oriented and data access are far.
2. Object Oriented language types and native database types are often different
SQL statement is “inside the quotes”.
3. There is no strong typing or compile-time type checking.
4. Intellisense is not available.
5. SQL and XML have query languages, objects to not

LINQ seeks bridging the gap
Here are some of the benefits of LINQ:

DataContext
  • Strongly typed database connectionDesigner
  • Relationships
a. One-to-one, one-to-many
b. Inheritance
c. Custom types

Intellisense and compiler validation
  • “Strongly typed query”
  • Super easy to write query

Conclusion:

Easy to use
  • Very powerful for read operations
  • Absolutely recommended for 2-tier app
  • Good for most ASP.NET architectures
    • Where Data Access Layer and Presentation Layer are in the same process
The ugly side of LINQ is;
  1. Doesn't have multi tier change tracking support
  2. ADO.NET Entity Framework is an alternative
  3. Works only with SQL Server






Resources:
http://wm.microsoft.com/ms/msdn/visualcsharp/anders_2007_01/Anders_0001.wmv











kick it on DotNetKicks.com