This is the first of a series of posts about web design using LINQ.
When you’re developing in a Visual Studio / SQL Server environment, chances are you’re going to be writing a fair amount of SQL to retrieve and update data. That’s been the only choice until now. Not that you’re all that thrilled about it…
There are two major issues with this approach, and we’ve had to live with these conditions. First, we get no help from Visual Studio in writing these queries; we build strings, and throw them at the database. When do we know we’ve made a mistake? When we try to execute the query.
Second, the data we get back doesn’t match the structure of our object hierarchy: do a join, and get back a rectangle of rows with columns from each of the tables.
With LINQ, we have a way to get data in a structure that matches our objects, and to get the power of IntelliSense and strong typing as we write the queries.
LINQ stands for Language Integrated Query. With LINQ, we write our query code inside Visual Studio, in C# or VB.Net, as part of our application. And because of that, Visual Studio will give us IntelliSense as we type, and will return our fields properly typed.
LINQ can do queries against SQL/Server, databases that you can access from DotNet, XML, and even in-memory collections. You can even do joins across technologies – for example, joining a SQL/Server table with an XML document.
In future posts, I’ll describe ways that LINQ can be used, how to use its tools to speed up your development process, and what to watch out for.
Give it a try!
- Ben Furino
.NET Programming Manager