1

I am struggling with picking up a new project coded in MVC. The original developer obviously didn't care one tiny bit. You know how that is. Anyway, they are using something beyond the Model interface, they are using both a DTO and Model. Can you please explain why anyone would do this? I am getting lost in the weeds because they also use EF, so when I need to update the database, I need to update 3-4 locations. Below is a screenshot - DTO is on the left.

DTO and Model Screenshot

And to top that off, they use something like below on almost all of the Controller Calls:

return contractorsQuery.ToList().Select(Mapper.Map<Contractor, ContractorDTO>);

I have tried reading and reading, but none of it is sinking in. Thanks so much!

CodeNotFound
  • 22,153
  • 10
  • 68
  • 69
Zach
  • 31
  • 1
  • 5
  • 1
    Possible duplicate of [Should services always return DTOs, or can they also return domain models?](http://stackoverflow.com/questions/21554977/should-services-always-return-dtos-or-can-they-also-return-domain-models) – aperezfals May 18 '17 at 18:09
  • 1
    There looks to be nothing wrong with this code. They are using separate viewmodel from their ef model. It's using AutoMapper to map between the two. The dev seems to have split the queries up into their own classes. Not how I'd do it, but there's nothing wrong with the code you posted. it seems like they cared a lot about separation of concerns. – Fran May 18 '17 at 18:47
  • ok thanks. Its a tiny app - 15 tables and 25 pages. Won't ever grow much bigger - just added functionality. – Zach May 18 '17 at 19:01

0 Answers0