Which layer of the application should contain DTO implementation

后端 未结 6 818
再見小時候
再見小時候 2021-01-31 04:11

Lately I\'ve been hearing a lot about DTOs and how useful they are but I can\'t find a good example of using it in ASP.NET context.

Let\'s say I use three tier architect

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-31 05:03

    Have a look at https://stackoverflow.com/a/6310507/1771365 added here as I don’t have enough reputation to add comments.

    Personally I would pass entitys between your Persistence layer and your business layer. As you are using MVC chances are your are going pass view models to your controllers. At which point I would map your view model to your DTOs(s).

    If you plan to use DTO between all of your layers then create a cross cutting project which you can then reference.

提交回复
热议问题