ASP.NET MVC - Code Usability Improvement (available now in v2011.1)

ASP.NET Team Blog
15 April 2011

Available now in the DXperience v2011.1 release, we've introduced a useful improvement for working with the DevExpress ASP.NET MVC Extensions that will help improve code usability.

Add Method For Collections

We're adding a useful new overload for our collections' Add methods. So the fluent HTML code in our MVC Extensions that looked like this:

var column = settings.Columns.Add("Total");
column.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
column.PropertiesEdit.DisplayFormatString = "c";

Will now look like this with v2011 volume 1 release:

settings.Columns.Add(column => { 
    column.FieldName = "Total";
    column.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
    column.PropertiesEdit.DisplayFormatString = "c";
})

Benefits

The benefit for you with the new Add method is that it avoids the var structure and makes your code more readable!

Thanks to a DevExpress customer who asked me during a recent webinar about using more lambda expressions in our MVC extensions.

What do you think of this code improvement? Drop me a line below, thanks!

Build Your Best - Without Limits or Compromise

Try the DevExpress ASP.NET MVC Extensions online now: http://mvc.devexpress.com

Read the latest news about DevExpress ASP.NET MVC Extensions

Download a free and fully-functional version of DXperience now: http://www.devexpress.com/Downloads/NET/

Follow MehulHarry on Twitter

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.