Thursday, July 29, 2010

Visual Studio 2010 - MVC 3 and DLR - Great New Feature

MVC 3 and the use of the Dynamic Keyword and DLR Infrastructure

As I already blogged about the dynamic keyword and it's power, what was very interesting was to see how MVC 3 leverages the DLR infrastructure that is now included with .NET 4.0.  


What was very cool was to see some of the new features of MVC 3 leveraging things such as strongly typed views in the controller.  Before your code may have looked like this ViewData["Mydata"] = "Sean's Data".


With MVC 3 you now have another object called ViewModel.YourField.  Where "YourField" would represent a dynamic value of any attribute on your model that is determined at runtime.  Very cool!!!  The only downside is that you do not have the intelli-sense, but given that you can flexibility a very nice feature added.


DLR Sidebar
So what is the DLR????  DLR stands for Dynamic Language Runtime and runs on top of the CLR or Common Language Runtime.  A very nice read on the DLR.  http://msdn.microsoft.com/en-us/magazine/ff796223.aspx.









Also included is a link to my blog entry for the dynamic keyword.  .NET 4.0 "dynamic" keyword versus, "var" keyword - anonymous types

No comments: