Archive

Archive for the ‘Programming’ Category

AutoMapper – A convention-based object-object mapper

April 30th, 2010 No comments

AutoMapper uses a fluent configuration API to define an object-object mapping strategy. It uses a convention-based matching algorithm to match up source to destination values. Currently, it is geared towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is better suited for serialization, communication, messaging, or simply an anti-corruption layer between the domain and application layer.

Conventions

Since AutoMapper flattens, it will look for:

  • Matching property names
  • Nested property names (Product.Name maps to ProductName, by assuming a PascalCase naming convention)
  • Methods starting with the word “Get”, so GetTotal() maps to Total
  • Any existing type map already configured

Basically, if you removed all the “dots” and “Gets”, AutoMapper will match property names.  Right now, AutoMapper does not fail on mismatched types, but for some other reasons.

Features rundown

AutoMapper supports:

  • Mapping of simple types
  • Mapping to arrays from any IEnumerable source
  • Custom member resolution, for that 1% case you have to do some extra mapping work
  • Polymorphic array mapping
  • Custom formatting for mapping from any type to a string
  • Global formatters
  • Null substitutes for formatting (i.e. a missing Product formats to “n/a”)
  • Profiles, for separating different sets of configurations (JSON vs. ViewModel vs. EditModel etc)

Other features include:

  • Convention of no null destination objects, ever.
  • No null destination array properties, ever.
  • A fluent configuration, with both a method chaining syntax (through Mapper) and object scoping (through a Profile)

For more information, please go to http://automapper.codeplex.com/

Categories: Programming Tags:

Visual Studio 2010 and .NET Framework 4 will be released today

April 12th, 2010 No comments

The new release of Visual Studio 2010 has plenty of compelling new features and updates that will make every developer more productive. For instance:

  • Visual Studio 2010 allows users target of the right platform for their application, including Windows 7, Windows Server 2008 R2, SQL Server 2008, SharePoint. Office, Windows Azure, and Windows Phone 7 applications using their existing skills.
  • Visual Studio 2010 is a rich, personalized development environment.  We know that software developers spend much of their time in the IDE, and features like the new editor and multi-monitor support make your time in Visual Studio more productive and enjoyable.

Teams are able to work more efficiently using Application Lifecycle Management tools. The Visual Studio 2010 team have done a great deal of work in Visual Studio 2010 to improve testing and debugging tools.  Features like IntelliTrace and easy project management help your team ensure high quality.

If you are an MSDN subscriber, later in the day on April 12th you can download Visual Studio 2010 from MSDN.

Free – Moving to Visual Studio 2010 e-book

April 9th, 2010 No comments

It’s a book that will help professional developers move from previous versions of Visual Studio (starting with 2003 and on up). It will cover the features of Visual Studio 2010 through an application. It will go through a lot of the exciting new language features and new versions of the most popular technologies without putting the emphasis on the technologies themselves. It will instead put the emphasis on how you would get to those new tools and features from Visual Studio 2010.

Get your copy here.

ASP.NET MVC 2 Released

March 12th, 2010 No comments

Scott Guthrie just announced yesterday that ASP.NET MVC 2 final release is available for VS 2008/Visual Web Developer 2008 Express with ASP.NET 3.5.

ASP.NET MVC 2 Features

  • New Strongly Typed HTML Helpers
  • Enhanced Model Validation support across both server and client
  • Auto-Scaffold UI Helpers with Template Customization
  • Support for splitting up large applications into “Areas”
  • Asynchronous Controllers support that enables long running tasks in parallel
  • Support for rendering sub-sections of a page/site using Html.RenderAction
  • Lots of new helper functions, utilities, and API enhancements
  • Improved Visual Studio tooling support
  • Can run side-by-side with MVC 1 (meaning you can have some apps built with V1 and others built with V2 on the same machine)

If you’re planning to use Visual Studio 2010 or Visual Web Developer 2010, they will have ASP.NET MVC 2 built-in.

Please click here to go to MS’s download page.

ReSharper 5 Beta 2 Released

February 19th, 2010 No comments

ReSharper 5 Beta 2 released, works with VS2010 RC build.

Improvements/Fixes:

  • Support for Visual Studio 2010 RC
  • Extended ASP.NET MVC functionality
  • Stable Structural Search and Replace
  • Multiple usability improvements

Learn more and download it.

Microsoft Visual Studio 2010 RC and .Net Framework 4 RC have been released

February 12th, 2010 No comments

Microsoft Visual Studio 2010 RC and .Net Framework 4 RC have been released and available for download. Please click on the link provided below to go to the download page.

http://www.microsoft.com/downloads/details.aspx?FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a&displaylang=en

ASP.NET MVC 2 RC is available for download

January 29th, 2010 No comments

These are the features that have been introduced in the ASP.NET MVC 2 Release Candidate release.

ASP.NET MVC validation scripts have been moved to their own file

To help reduce conflicts with other Ajax libraries, the built-in ASP.NET MVC validation scripts are now in a separate JavaScript file.

ASP.NET MVC validation scripts can be included at the top or bottom of a page

The server component that renders the client validation metadata now renders the metadata into a JavaScript variable. This allows the validation scripts to be included either at the top of the page or at the bottom, because the scripts will look for the variable and load the metadata when it is available.

ASP.NET MVC validation scripts support globalization

When the required ASP.NET Ajax globalization scripts are included in a page, the validation logic uses the culture-specific data for data types (such as dates and numbers) when it validates input text. The new Html.GlobalizationScript helper method can be used to render a reference to the globalization script for the current culture.

Html.ValidationSummary helper method can display model-level errors

Instead of always displaying all validation errors, the Html.ValidationSummary helper method has a new option to display only model-level errors. This enables model-level errors to be displayed in the validation summary and field-specific errors next to each field.

T4 templates in Visual Studio generate code that is specific to the target version of the .NET Framework

A new property is available to T4 files from the ASP.NET MVC T4 host that specifies the version of the .NET Framework that is used by the application. This allows T4 templates to generate code and markup that is specific to a version of the .NET Framework. In Visual Studio 2008, the value is always .NET 3.5. In Visual Studio 2010, the value is either .NET 3.5 or .NET 4.

Here’s the download link:

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=3b537c55-0948-4e6a-bf8c-aa1a78878da0

Categories: Programming Tags: ,

NHibernate vs Entity Framework: a performance test

September 21st, 2009 No comments

I just found an interesting comparison in performance of two common ORM frameworks: Microsoft Entity Framework and NHibernate. Here’s a quick summary of the performance comparison:

Operation / Number of operations NHiberante – 4K Entity Framework – 4K NHiberante – 40K Entity Framework- 40K Winner
Store 37.37 9.19 1500 98 Entity Framework
Read over relations 1.01 0.54 10.13 4.18 Entity Framework
Read by ID 3.06 25.22 246 230 NHibernate with smaller amount of objects
Update 6.61 7.34 77 72 Both
Delete 3.35 16.76 58 1824 NHibernate

If you’re interested in the details of the performance measurements, please go to GregDoesIt.com.

Multi-Monitor Support in Visual Studio 2010

September 1st, 2009 No comments

In Visual Studio 2008,  all documents/files/designers are hosted within a single top-level window – which unfortunately means that you can’t partition the IDE across multiple monitors.

VS 2010 addresses this by now allowing editors, designers and tool-windows to be moved outside the top-level window and positioned anywhere you want, and on any monitor on your system.  This allows you to significantly improve your use of screen area, and optimize your overall development workflow.

If you work on a system that has multiple monitors connected to it, you will find the new multi-monitor support feature within VS2010 a big productivity boost. But if you don’t already have multiple monitors connected to your computer, this might be a good excuse to get some…

For more information, please see the original post at:

http://weblogs.asp.net/scottgu/archive/2009/08/31/multi-monitor-support-vs-2010-and-net-4-series.aspx

Visual Studio Addon: NArrange

August 11th, 2009 No comments

NArrange is a .NET code beautifier that automatically organizes code members and elements within .NET classes.

Why You Should Use NArrange?

There are several reasons you may want to consider using NArrange for your .NET software project:

  • Reduces the amount of time developers spend arranging members within code files. With NArrange, you don’t need to worry about where you place a new member definition in a class… just type away and run NArrange prior to compilation. After formatting, the new member will be automatically moved to the appropriate location in the source file.
  • Helps enforce coding style standards
  • When used as part of check-in procedures, NArrange can help reduce source code repository conflicts.
  • NArrange can automatically group similar code members into predefined region blocks, if supported by the language (C# and VB).
  • Reduces the amount of time spent searching for specific members in a code file. Through standard arrangement of source code files, every member of the team will know exactly where in a file to look for private fields, constructors, etc.
  • Flexibility – NArrange allows you to configure how members are organized (grouping, sorting, regions, etc.)
  • Sort Usings

For more information about this free product (open source), please go here.