LINQ, BB’s and the HTTP’ness

The Language Integrated Query (LINQ) demo during the PDC demo was exciting. There was applause all around whenever different products were shown and different speakers were introduced, yet when the LINQ demo was shown there was a lot of talk within the crowd, oohs and aahs, and a bunch of OMG-this-is-cool’s. The attendee sitting next to me pulled out his notepad and started writing down everything he saw. After two hours of keynote before it, it was the only thing worthy to write down.


Anders gave the demo along with Don Box as part of a large multi-technology demo showing off the LINQ project, Indigo, Atlas and Avalon. The LINQ part was first and formed the foundation of the rest of the demo. The demo was written using the new preview version of the C# 3.0 compiler and an object-relational API we refer to as D-LINQ, both of which I’ve been working on for the last two years. Similar language features that enable queries in C# will eventually be in VB as well, or BB as Anders was heard to call it by the automatic voice to text translator overlaid on the keynote’s projection screen. Don’t you just love technology?


Anders had Don (his code monkey) write a query against the framework to find all the processes with a working set greater than 4 MB. The code looked something like this.



var q = from p in Process.GetProcesses()

        where p.WorkingSet > 1024 * 1024 * 4

        select new {p.ProcessName, p.WorkingSet};

foreach(var p in q) {

    Console.WriteLine("{0,-30} {1}", p.ProcessName, p.WorkingSet);




The new C# 3.0 language has a construct known as a query expression. It looks a little bit like SQL yet not exactly. The select clause comes at the end. It written this way so the ‘range variables’ are specified up front making it possible for intellisense to aid you as you type. The select clause specifies a single expression, however you can use a new language feature known as anonymous type initializers (show in this example) to project the results into a new shape.


After the queries were written, Anders turned the floor back over to Don who with the help of Chris Anderson went off to turn the application into a web service. At this point Don muttered something about the protocol layer, noting its HTTP’ness. That’s when I knew I had a blog post.


Anyway, I’m busy working at the PDC, no time to explain more. Check out the LINQ online website for more details. Download the preview compiler and the whitepapers. There’s also a download for the VB 9.0 preview with a bunch of XML integration. Check that out too. J