Posts

Showing posts with the label automapper

Using AutoMapper in Entity Framework Projections

Image
AutoMapper is a wonderful tool that lets us convert one class to another using fluently-defined configurations. It is useful when there is a need for multiple mappings, such mappings from persistence model classes to domain model classes or mapping from domain model classes to viewmodels. In this post we are going to look at how to use AutoMapper with Entity Framework for projections.

Automapper Quickstart

Image
Mapping code is ubiquitous in most web applications. The most common use case is when mapping DTO's to business entities or from business entities to view models. Manually writing mapping code, though necessary, is tedious, time-consuming, error prone, and hard to maintain. Fortunately there are libraries such as AutoMapper that help us with the task.