ASP.NET MVC, PLINQ, and the Entity Framework

In the last week Microsoft release three exciting CTPs (Community Technology Previews):
  • ASP.NET 3.5 Extensions Preview
  • Microsoft Parallel Extensions to .NET Framework 3.5
  • ADO.Net Entity Framework Tools

ASP.NET 3.5 Extensions Preview, released yesterday, includes a new project by the ASP.NET team called ASP.NET MVC.  The Model View Controller pattern is one of the oldest proven patterns in object-oriented programming dating back to Smalltalk.  The Java world has been using an MVC implementation called Struts for years created by the Apache Software Foundation.  .NET developers on the other hand has been primarily using ASP.NET Web Forms and MVP (Model View Presenter) which integrates well with the WebForms platform.  At the Patterns and Practices Summit in Redmond last month Michael Puleio, Chris Tavares, and Blaine Wastell gave a talk on the Web Client Software Factory described the difference between MVP and MVC the following way.  MVP is similar to MVC except that the View interacts receives input from the user and interacts with the presenter vs MVC where the controller receives the input which intacts with both the view and model.  Here is a slide from their deck used by permission (thanks Blaine):

So what is ASP.NET MVC?  Well it is an alternative Web Forms.  So instead of primarily using the System.Web.UI.WebControls namespace, you will use the System.Web.Mvc namespace to build your applications. Web Forms is not going away or being deprecated.  It will remain as a choice for modeling your web applications.   So before .NET developers either used Web Forms, thier own custom extension of the ASP.NET framework, or 3rd party or open source framework like MonoRail.  Now .NET developers and architects will have another framework choice.  It is planned for release in the first half of 2008.

Update (Dec 11, 2007): Blaine announced last week about a Model View Presenter Bundle that just shipped and is available for download from CodePlex which includes Composite Web Application Block QuickStart.

Microsoft Parallel Extensions to .NET Framework 3.5, December 2007 Community Technology Preview includes PLINQ (Parallel Language Integrated Query). This adds a new namespace, System.Linq.Parallel, to LINQ for parallel exectuion that takes advantage of the growing number of cores on desktop and servers.  Here is an excerpt of Joe Duffy and Ed Essey’s article on PLINQ, Parrallel LINQ: Running Queries on Multi-Core Processors:

"PLINQ is a query execution engine that accepts any LINQ-to-Objects or LINQ-to-XML query and automatically utilizes multiple processors or cores for execution when they are available. The change in programming model is tiny, meaning you don’t need to be a concurrency guru to use it."

LINQ is a new language feature in C# and VB.NET that allows SQL like query syntax right in the language.  This is new for .NET 3.5 which is a target for Visual Studio 2008. So many times you see SQL in quotes in .NET code and it is very unnatural and requires a syntax headache of quotes because you have SQL quotes inside C# quotes for example:  

string query = "SELECT CustomerId FROM Customers WHERE CustomerName LIKE ‘" + custName + "%’";

In this example the programmer opens a single quote after LIKE in SQL but closes a quote in C# and then must do the reverse at the end of the statement.  LINQ allows for a "natural" query language native to C#.  LINQ also allows for stronger typing.  In the previous example, all of the SQL language is just a string in C#, so the C# compiler doesn’t know a table from a column or a keyword, its all just a text string.  One way before LINQ of getting strong typing .NET database code was using strong typed DataSets in ADO.NET, but LINQ uses a completely different approach and I encourage you to explore it if you haven’t already.

Finally, ADO.Net Entity Framework Tools Dec 07 Community Technology Preview includes a "preview release of the ADO.NET Entity Designer which enables users to visually design model and mappings using Visual Studio 2008".  LINQ and the Entity Framework go together well because LINQ makes querying part of the language and the Entity Framework allows the developer and/or architect to model the data similar to O/R mappers and reduce plumbing code.  Here is an article on MSDN that explains it nicely: The ADO.NET Entity Framework Overview.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s