User Group Recap: LINQ

January 10th, 2007

Miller Inn Meeting Last night was the .NET User Group meeting covering LINQ. Dave Bost did a great job fielding many questions from room full of curious developers. Prior to the meeting I had some concerns about how LINQ may enable developers to start inlining queries into the database directly from a web page code-behind and completely undermine a carefully layered architecture. While that is still possible, just as it is with ADO.NET, I learned that LINQ is not just about hitting the database. It is really more about querying and munging data you already have in memory.

For example, if you have a collection of City objects with over 1000 cities you can create a LINQ reference to it with a query that limits to cities which start with the letter "A". This was one of his examples. And if you were to change the name of a city in the list from Aspen to Brooklyn that city would not be included the next time you iterate over the list. I was surprised to learn that the list is evaluated when it is used. That will surely be an issue which comes up many times as people start using LINQ. Normally a collection is not going to modify itself after it is defined. It is more like you are attaching a function to the datasource which runs each time the value referenced which returns a fresh collection instead of an unchanging static collection. This somehow uses Lambda Expressions. In the least it will be a good piece of trivia to be used as an interview question down the road.

Trying LINQ

Miller Inn Meeting The one question I wanted to ask for the sake of everyone watching the presentation was how to add the pre-release features of LINQ so that they can be used in Visual Studio and then to remove the software safely afterward so you can continue on with your C# 2.0 limitations preserved. Afterward I had a quick chat with Dave Bost along with Larry Clarkin (from our previous meeting) and the answer is virtualization. What you want to do is install a copy of Windows with your development tools inside of a Virtual PC and optionally host it inside of Virtual Server. Virtual Server is a a free product, so it will give you an excellent way to try out beta releases without impacting your main development environment. I run virtual server on my laptop and have multiple environments I can fire up anytime I choose to use them, such as WinXP for .NET 1.1, WinXP for .NET 2.0, Windows 2003 Server for test deployments and Vista to try out IIS7. Another host for C# 3.0 is surely on the horizon.

Dave had a few links he wanted to let everyone know about. So here they are:

Comments are closed.