0

As an example:

I have a data transfer object mapped from my business entity.

I have a Controller, that calls business logic handler class, that returns List<MyDTO> result.

Can I have List<MyDTO> as a public member in my ViewModel so that I can load List<MyDTO> result into my ViewModel, and afterwards use foreach and so on from my View, and take data from List in ViewModel to show it in a View?

Or should DTO be used ONLY for transfer, not as a ViewModel public member?

RickL
  • 2,940
  • 10
  • 31
  • 35
nuclear sweet
  • 949
  • 9
  • 24
  • 2
    Keep view models and DTOs separately to save maintenance issues in future. Use mapping libraries like auto mapper to map them in controller. – Sunny Apr 25 '14 at 20:37
  • Thx. I was think the same way, just need some confrim. – nuclear sweet Apr 25 '14 at 20:41
  • You may, nothing can stop you from doing this. however as suggested if your DTO and viewModel look exactly the same then autoMapper can help save time. – highwingers Apr 25 '14 at 22:22

0 Answers0