In this part I will show how we can use a customer value formatter (CustomFormatter) to format our mapped data into single “Number of Order:” and plural “Number of Orders:”.

First the Domain and Dto (data transfer object)

Now we will introduce a CustomResolver and Formatter, for the Formatter we are inheriting from IValueFormatter

For our mapping code we will use a block for options, so that after resolving the value, it would format it.

From the view we can see that the first order is displaying Order rather than Orders.

In the last part of the series I will show how to move all your mapping code to startup, so that it would speed things up.

Previous Post
Part 1 (NullSubsitution)
Part 2 (Flattening by Convention)
Part 3 (Nested Mapping)
Part 4 (Projection)
Part 5 (CustomResolver)