Archive for the 'Automapper' Category

Automapper: Mapping Objects Part 7 of 7 (Startup Registration)

Tuesday, March 15th, 2011

In this last part of the series I wanted to talk about how to register automapper at startup of your web application, in doing so it would help speed things up with automapper. There are many ways to do it, the easiest way is to just have a method inside Global.asax.cs file in your Application_Start [...]

Share

Automapper: Mapping objects Part 6 of 7 (CustomFormatter)

Monday, March 14th, 2011

In this part I will show how we can use a customer value formatter to format our mapped data into single “Number of Order:” and plural “Number of Orders:”. First the Domain and Dto (data transfer object) ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [...]

Share

Automapper: Mapping objects Part 5 of 7 (CustomResolver)

Friday, March 11th, 2011

In Part 5, we will use a powerful feature that automapper allows us, which is CustomResolver. Lets look at our Domain Object which contains a boolean field called ShipToHomeAddress, what we will do is map those boolean to a string value with “Yes” or “No”. ?View Code CSHARP1 2 3 4 5 6 7 8 [...]

Share

Automapper: Mapping objects Part 4 of 7 (Projection)

Thursday, March 10th, 2011

In Part 4 we will see how we can use projection to map inner objects for example a DateTime field. Again our domain and Dto (Data Transfer Object) looks like ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 //Order [...]

Share

Automapper: Mapping objects Part 3 of 7 (Nested Mapping)

Wednesday, March 9th, 2011

In this part we will use the same OrderDto Object that we had previously but we will let Automapper to map the inner objects. Once again here is the Domain Objects First ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [...]

Share

Automapper: Mapping objects Part 2 of 7 (Flattening by Convention)

Tuesday, March 8th, 2011

In this part I will be showing how Automapper uses flattening by convention. If we look at our OrderDto we will see that it has a IEnumerable of OrderItemsDto and also something called OrderNumber. This is the type of object we want to send to our presentation layer. ?View Code CSHARP1 2 3 4 5 [...]

Share

Automapper: Mapping objects Part 1 of 7 (NullSubsitution)

Monday, March 7th, 2011

Recently I gave a talk on Automapper in Ottawa .Net Community, so I though I would post the main ideas of the presentation here also. The demo was based on an Order System where there were just 3 tables/classes, “Order”, “Customer” and “OrderItems” From the diagram we can see that a Customer has a Bio [...]

Share