Skip to content

Interface base Code generation

chaowlert edited this page Jan 24, 2021 · 1 revision

Generate mapper from interface

Annotate your interface with [Mapper] in order for tool to pickup for generation.

This is example interface.

[Mapper]publicinterfaceIProductMapper{ProductDTOMap(Productcustomer);}

You can add multiple members as you want. All member names are flexible, but signature must be in following patterns:

[Mapper]publicinterfaceICustomerMapper{//for queryableExpression<Func<Customer,CustomerDTO>>ProjectToDto{get;}//map from POCO to DTOCustomerDTOMapToDto(Customercustomer);//map to existing objectCustomerMapToExisting(CustomerDTOdto,Customercustomer);}

If you have configuration, it must be in IRegister

publicclassMyRegister:IRegister{publicvoidRegister(TypeAdapterConfigconfig){config.NewConfig<TSource,TDestination>();}}

Clone this wiki locally