My presentation at DevTeach went very well. As a matter of fact I was impressed to see so many people even though I was in competition with Carl Franklin and Rod Paddock.
I want to thanks everyone who was there.
Eric De Carufel, Parallel Extensions, Parallel Computing, C#, .NET, Design Patterns, OOP, Famework.NET 2.0, 3.0, 3.5, Visual Studio.
My presentation at DevTeach went very well. As a matter of fact I was impressed to see so many people even though I was in competition with Carl Franklin and Rod Paddock.
I want to thanks everyone who was there.
Did you ever try to spit out XML data from a SQL database? Of course you can use the “FOR XML AUTO” clause but it will throw you something like this:
SELECT TOP 6 ProductID, ProductName, UnitPrice FROM Products FOR XML EXPLICIT
<root> <Products ProductID="1" ProductName="Chai" UnitPrice="18.0000" /> <Products ProductID="2" ProductName="Chang" UnitPrice="19.0000" /> <Products ProductID="3" ProductName="Aniseed Syrup" UnitPrice="10.0000" /> <Products ProductID="4" ProductName="Chef Anton's Cajun Seasoning" UnitPrice="22.0000" /> <Products ProductID="5" ProductName="Chef Anton's Gumbo Mix" UnitPrice="21.3500" /> <Products ProductID="6" ProductName="Grandma's Boysenberry Spread" UnitPrice="25.0000" /> </root>
With “FOR XML EXPLICIT” you can have a little more control:
SELECT TOP 6 1 AS Tag, NULL AS parent, ProductID AS [Product!1!ID], ProductName AS [Product!1!Name!element], UnitPrice AS [Product!1!Price!element] FROM Products FOR XML EXPLICIT
<root> <Product ID="1"> <Name>Chai</Name> <Price>18.0000</Price> </Product> <Product ID="2"> <Name>Chang</Name> <Price>19.0000</Price> </Product> <Product ID="3"> <Name>Aniseed Syrup</Name> <Price>10.0000</Price> </Product> <Product ID="4"> <Name>Chef Anton's Cajun Seasoning</Name> <Price>22.0000</Price> </Product> <Product ID="5"> <Name>Chef Anton's Gumbo Mix</Name> <Price>21.3500</Price> </Product> <Product ID="6"> <Name>Grandma's Boysenberry Spread</Name> <Price>25.0000</Price> </Product> </root>
But this SQL syntax is a bit odd. It gets worst when you try to add multiple level in your XML output. SQL Server 2005 provides another constrct: “FOR XML PATH”. Here is the same sample:
SELECT TOP 6 ProductID AS [@ID], ProductName AS [Name], UnitPrice AS [Price] FROM Products FOR XML PATH('Product')
This will produce the same output as the previous EXPLICIT sample but the syntax is much more understandable.
Anyone who writes web applications knows that web development is not easy. Developers wrangle with a soup of technologies distributed across multiple tiers. We live in a world where programmers accept the fact that they need to know four or five different languages, tools, and environments just to get a site up and running. In ancient times, the Egyptians built marvelous structures despite the primitive tools that the workmen used. Building a pyramid took most of the national resources of wealth and labor. Today, we build structures which are vastly more complicated and yet require only a tiny fraction of the resources. The difference is in the tools and the infrastructure.
In a similar way, Volta significantly improves web development. Programmers write web applications using familiar .NET languages, libraries, and tools. Volta splits the application into multiple parts potentially running on different tiers, say, client and server. Client code needs only a minimal, JavaScript-enabled browser, though Volta will take advantage of additional runtimes that may be present.
Programmers simply refactor classes that need to run on tiers other than the client and Volta injects the boilerplate code for communication, serialization, synchronization -- all the remoting code. The developer enjoys all of the benefits of .NET: a great debugger, test tools, profiling, intellisense, refactorings, etc.
Just how simple is Volta? Let's write an application that uses a button to query the server for a string and displays that string to the client: the hello world web application.
Now, let's write the code for the web page. We need a Div for the output and an Input for the interaction. Of course, we could have constructed the page elements with HTML/CSS instead.
using System; using Microsoft.LiveLabs.Volta.Html; using Microsoft.LiveLabs.Volta.Xml; namespace HelloWorld { public partial class VoltaPage1 : Page { public VoltaPage1() { var output = new Div(); var b = new Input(); b.Type = "button"; b.Value = "Get Message"; b.Click += () => output.InnerHtml = C.GetMessage(); Document.Body.AppendChild(output); Document.Body.AppendChild(b); } } internal class C { public static string GetMessage() { return "Hello, World"; } } }
But we want to produce the message on the server. Time to refactor.
Browser clients call the server, the "Origin", because this ensures the message will come from the same server that supplied the HTML.
[RunAtOrigin] internal class C { public static string GetMessage() { return "Hello, World"; } }
That is it. Try it out.
Now, click "Get Message".
Great. But is it cross-browser compatible?
Yes. And you can debug it.
You can even debug across tiers.
There is a lot more to Volta in the first technology preview which was made publicly available at 11 am PST today and there will be a lot more to come.
Still skeptical? Try it out for yourself.