26
Object-to- object mapping © Oleksii Dukhno @ Lohika Systems

Auto mapper public

Embed Size (px)

Citation preview

Page 1: Auto mapper public

Object-to-

object

mapping

© Oleksii Dukhno @ Lohika Systems

Page 2: Auto mapper public

Complexity of software

Page 3: Auto mapper public

Tools for fighting with the

complexity

Page 4: Auto mapper public

Abstractions and model

Page 5: Auto mapper public

Models, DTO and ViewModels data transfer object = model data only

view model = model data + behavioral aspects

data transfer object != view modelbut

view model = data transfer object

Page 6: Auto mapper public

Models, DTO and ViewModels

Flattening

Page 7: Auto mapper public

Why using o-2-o ?

Encapsulate Flattening Logic

Page 8: Auto mapper public

Why using AutoMapper ?

Encapsulate Flattening Logic

Result = Neater code,

Simpler support,

Better understanding

Page 9: Auto mapper public

How to use AutoMapper ?

Mapping Through

Convention

Source/Destination Properties Names

Convention

Mapping Through

Configuration

Projection

Value Resolver

Type Converter

Ignore

TestMapping

Validate Configuration

Page 10: Auto mapper public

Mapping Through Convention

Page 11: Auto mapper public

Mapping Through ConfigurationIgnore

Will throw AutomapperConfigurationException

Page 12: Auto mapper public

Mapping Through ConfigurationIgnore

Page 13: Auto mapper public

Mapping Through ConfigurationProjection

Page 14: Auto mapper public

Mapping Through ConfigurationProjection

Page 15: Auto mapper public

Mapping Through ConfigurationType Converter

Page 16: Auto mapper public

Mapping Through ConfigurationType Converter

Page 17: Auto mapper public

Mapping Through ConfigurationValue Resolver

Page 18: Auto mapper public

Mapping Through ConfigurationValue Resolver

Page 19: Auto mapper public

Mapping Through ConfigurationValue Resolver

Page 20: Auto mapper public

Using AutoMapper in Allocine-CMS

Page 21: Auto mapper public

Using AutoMapper in Allocine-CMS

Page 22: Auto mapper public

Emit Mapper Key Sufficiencies

Really fast (close to hand written code)

Supports mono

Page 23: Auto mapper public

Emit Mapper - simplest example

CODE

Page 24: Auto mapper public

Emit Mapper – custom converter

CODE

Page 25: Auto mapper public

Emit Mapper – post processing

CODE

Page 26: Auto mapper public

Emit Mapper vs. AutoMapper

Style Facade Speed Open Source Reliability

Emit Mapper Functional No The Best Yes Low

AutoMapper OO Yes Good Yes High