-
Notifications
You must be signed in to change notification settings - Fork 42
AutoMapper Usage
Wendy Yao edited this page Mar 15, 2020
·
3 revisions
A mapper was needed to prevent cyclic references when having certain API calls (getAll).
AutoMapper was chosen as it is one of the most popular mapping applications in C#, and saves time when mapping to dissimilar types.
- Reduces duplicate code
- Saves time writing boilerplate mapping classes
- Easy to use
- Add AutoMapper reference in StartUp.cs
- Create mappings in a mapping class, mapping from model to DTO and DTO to model.
- Inject mapper to relevant controller classes
- When returning an object, return the DTO by using the mapping class we created as shown below.
- Home
- Data Model
- Architecture
- API Documentation
- Front End Documentation
- Testing
- Prototyping
- Other
- Contributing Guidelines and Etiquitte
- Labels
- License
- Admin