LINQ is Not Just for SQL
Posted in LINQ, Programming on January 6th, 2009 by admin – Be the first to comment![]()
![]()
0103091353.jpg, originally uploaded by slmcmahon.
0103091352.jpg, originally uploaded by slmcmahon.
0103091348.jpg, originally uploaded by slmcmahon.
0103091109.jpg, originally uploaded by slmcmahon.
0103091101.jpg, originally uploaded by slmcmahon.
I work in a large organization on both client and server .NET code. A few months ago we were approved to use .NET 3.5 in our server applications, but for client applications we are still restricted to 2.0 code in order to support all clients, some of which are unfortunately still using Windows 2000. Once I started using LINQ syntax in my server code, it seemed like major drudgery to go back and work on our client applications. I noticed though, after we switched over to Visual Studio 2008 for our client code, that a code analyzer that I use was suggesting that I use local variable inference and object initializers. This was irritating and frustrating so I decided to do some web research to find out how to disable those checks.
What I found in this article was surprising. You actually CAN use that syntax in .NET 2.0 targeted applications in Visual Studio 2008. Apparently the environment is smart enough to translate this syntax into something that can be compiled into .NET 2.0 assemblies.
After I spent some more time looking into that, I stumbled upon the LINQBridge Project. This library actually allows you to use LINQ to Objects syntax in your .NET 2.0 code. It is doesn’t support LINQ to SQL and LINQ to XML, but being able to use extension methods, comprehension queries and lambda expressions against collections is certainly enough to get me excited about it.
In the organization that I work in, there are actually thousands of machines that DO have the .NET 3.5 framework, so I was concerned about how those machines would handle this library. According to the LINQBridge site, having .NET 3.5 on the target machine is no problem. It states “The presence of Framework 3.5 does not impede LINQBridge in any way. If your project references LINQBridge during compilation, then it will bind to LINQBridge’s query operators; if it references System.Core during compilation, then it will bind to Framework 3.5’s query operators.”
I’m a long-time reader of Jeff Atwood’s blog, “Coding Horror“. This is no doubt the best one that I’ve read yet: Programming: Love It or Leave It.