I have a complex mapping logic between my database objects and domain objects. Hence, I am not using any third-party library like AutoMapper. I am wondering what would be a better code design:
Option #1. Having a mapper abstracted as IServiceNameMapper and inject as a dependency into IServiceName
Option #2. Write extension methods to database objects and domain objects to convert between them.
I am leaning towards option #1 as I get a nice separation of concern, wherein the mapping logic is abstracted away from the core service logic and injected as a dependency into service. This also gives me ability to extend or change the mapping logic in the future without having to change the service implementation.
Any thoughts?
Aucun commentaire:
Enregistrer un commentaire