LINQ in C# Web Applications

I’m a big fan of the Web Application type that was previously available as an add-on to Visual Studio 2005 but thankfully got promoted to a standard citizen with Service Pack 1.

So with a little more time on my hands lately I’ve been delving into the wonder that is LINQ — part of the forthcoming Orcas release of technologies.

For those who’ve been living under a rock LINQ is a set of extensions to .NET that let you perform queries on objects in much the same way you would do on a database with SQL (except the syntax is backwards by comparison).

Now while the LINQ Preview CTP installs LINQ projects for C# Class Libraries, Windows Applications and Console Applications it inconveniently misses-out Web Applications!

You can drop this ZIP file in your %UserProfile%\My Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual C# to gain a new ASP.NET LINQ Web Application project type for you to start with as often as you like as shown:

Window of the LINQ To SQL templates available

Or if you want to modify an existing Web Application simply:

  1. Open up the .csproj file in Notepad and replace <Import Project=”$(MSBuildBinPath)\Microsoft.CSharp.targets” /> with <Import Project=”$(ProgramFiles)\LINQ Preview\Misc\Linq.targets” />
  2. Add project references to:
    System.Data.DLinq
    System.Query
    System.Xml.XLinq
    

Hopefully more LINQ related posts as I get to grips with it.

[)amien

0 responses to LINQ in C# Web Applications

  1. Avatar for

    Information is only used to show your comment. See my Privacy Policy.