Mind your languages with Microsoft LINQ

Data-access sticking plaster?

Microsoft .NET logo

We've been hearing a growing amount this year about LINQ - Microsoft's Language Integrated Query. You can expect a lot more next year, starting in February as Microsoft launches Visual Studio 2008 and SQL Server 2008. LINQ promises to close the skills and knowledge gap for developers using C# and VisualBasic trying to connect to different data types and sources.

Before Visual Studio and SQL Server 2008 hit, here's what you as a programmer need to know about LINQ.

LINQ was created as the solution to a communication problem. Most modern programming languages are Object-Oriented (OO) while much of the world's data is stored in relational databases. Application programmers are used to dealing with things such as objects, classes and methods but they are not usually familiar with SQL - the language used to query relational databases.

As Anders Hejlsberg - the noted language expert and designer of Microsoft's C# - has argued, this has created: "An impedance mismatch today between general-purpose programming languages and databases. LINQ adds native query capability into programming languages such as C# and VisualBasic."

At a very simplistic level, LINQ can be seen as an OO querying language that can be understood and used by OO programmers and yet run against relational structures. But whilst this describes the way that it will often be used, LINQ actually does a lot more and is described by Hejlsberg and colleague Don Box here as: "General-purpose query facilities added to the .NET Framework [that] apply to all sources of information, not just relational or XML data."

So LINQ allows application programmers of an OO mindset to query any data source (Relational, OO and XML) in a way that they find intuitively easier. It is not, despite what some people have written, a replacement for SQL. To be explicitly clear about this, whilst DBAs are, of course, free to use LINQ if they so wish, there is no suggestion that it will become their language of choice.

For programmers, one of the best resources I've found for getting one's brain around LINQ is the intriguingly labeled 101 LINQ Samples for Visual C# that can be found here. Intriguing, why? Because there are actually 99 samples. Oh, those Microsoft clowns.

So does LINQ open the door to a pain-free world? I never said that. Most people would agree that there is an "impedance mismatch" between general-purpose programming languages and databases. We can, though, essentially address this problem from either end.

Sponsored: Driving business with continuous operational intelligence