Saturday, February 21, 2009

Load a DataTable with LINQ

The other day a colleague of mine needed to load a strongly typed ADO.NET DataTable from a LINQ to SQL query. We didn't find any good solutions using "The Google", so after a bit of hacking we came up with something similar to this:

    PeopleDataSet ds = new PeopleDataSet();
    using (PeopleDataContext context = new PeopleDataContext())
    {
        (from p in context.Persons
         select new
                    {
                        Row = ds.Person.AddPersonRow(p.Id, p.FirstName, p.LastName)
                    }).ToList();

    }

After ToList() executes we should have a DataTable populated with the results of our query.

#    Comments [0] |
 Friday, December 14, 2007

The Three “R”s of Volta

A prevalent theme in the Volta documentation is the concept of the three “R”s. These three principles are at the heart of what Volta attempts to provide for developers.  They are retargeting, remodulating, and refactoring.

Retargeting

To me this is the coolest aspect of Volta and the feature that makes it a very interesting technology. At its core Volta is a compiler or more accurately a recompiler.  Instead of recompiling the source code Volta uses a technique called MSIL rewriting. This is what enables the developer to write client-side browser code in C#. Since all CLR languages compile to MSIL, Volta can use that as the common denominator. Volta is capable of MSIL to MSIL, and MSIL to JavaScript conversion.

Remodulating

Another goal of the Volta toolset is seamless cross-browser support. As the documentation states:

 Volta hides as many browser-specific differences as possible, but still allows developers to leverage the unique capabilities of particular browsers. Instead of targeting solely the intersection of browser capabilities, Volta targets the entire union, but makes the intersection browser-agnostic. This is browser remodulating.

Remodulating also deals with the debugging experience. Regardless of the browser platform developers will be stepping through their application code within Visual Studio. That's assuming of course that your target is either IE or FireFox which are the only browsers supported in the current release.

Refactoring

Volta refactoring is about enabling developers to create their applications while deferring decisions about what tier a particular component will run in. In my opinion this will be the most controversial feature of the toolset.  Larry O’Brien has some reservations about it:

This sounds like a bad idea to me. You can't refactor away the difference between an in-memory method call and an Internet message: one happens in nanoseconds and the other in milliseconds

I have some questions of my own about this. The docs claim that:

During development, all code runs in the client for ease of testing and debugging.

What are the implications of this? Not every .NET class is meant to run in a browser context. Does Volta offer any automatic guidance with regard to this? The notion of clicking a “Split Tiers” check box and decorating a class with a [RunAtOrigin] does seem implicitly powerful, I’m just curious to know where the model breaks down. I will try to answer these questions and others as I dig deeper into the framework.

#    Comments [0] |
 Wednesday, December 05, 2007

Volta



It's kind of ironic.  This morning I was seriously considering taking a look at the Google Web Toolkit.  This is despite the fact that GWT is targeted at Java developers, which I am not.  It's just that GWT seems like such a useful idea - I wanted to play with it a bit.

Luckily Microsoft has, apparently, decided to put out a framework that allows developers to build rich internet applications without having to do a ton of JavaScript coding.

It's called Volta and at first glance it seems pretty cool.

When I was doing a lot of work with ASP.NET AJAX last year, the idea of coding in a more productive language and environment than JavaScript kept coming up again and again.  There was Script# at the time, but I didn't get a chance to look into it as much as I would have liked.

This certainly seems like a great development.  Maybe this even brings .NET developers one step closer to what Joel Spolsky described a few month ago.

Now…on to the samples, tutorials, and docs!

#    Comments [0] |
 Wednesday, November 21, 2007

2006 Beantown .NET Ajax Slides

Here are the slides from my 2006 Beantown .NET talk on ASP.NET Ajax.

beantown_ajax.ppt (636.5 KB)
#    Comments [0] |