MappingGenerator provides code actions for generating complete mapper class with desired mapping methods. There are two code actions for that purpose:
Generate mapper for
- Available from the context action on type. Automatically use the selected type as a one of mapping sides. The second type should be selected via config window.Generate complete mapper
- Available inside the namespace context, no need to have access to any type source code. Both mapping sides should be selected via config window.Generate Mapper
config window allows us to add the following kinds of method to mapper type:
A
to type B
. Method signature: B Map(A source)
B
to type A
. Method signature: A Map(B source)
A
with values from argument of type B
. Method signature: void Update(B source, A target)
B
with values from argument of type A
. Method signature: void Update(A source, B target)
A
to type B
. Method signature: IQueryable<B> ProjectTo(IQueryable<A> source)
B
to type A
. Method signature: IQueryable<A> ProjectTo(IQueryable<B> source)
Each method can be generated as:
Example usage of Generate complete mapper
can look as follows: