Returning NHibernate mapping classes from WCF services

后端 未结 2 2048
抹茶落季
抹茶落季 2020-12-19 22:07

I have a server that handles the database access and a client that consumes the information. The communication from the client to the server is through a WCF service.

<
相关标签:
2条回答
  • 2020-12-19 22:17

    Yeah, you probably want a DTO for this. It's usually considered better to not pass your data objects to the outside world, but also passing hibernate objects directly out of a service can give you some weird behavior, especially if you have lazily loaded collections.

    0 讨论(0)
  • 2020-12-19 22:34

    Use data-transfer objects to move the data from the server to the client. Your business (domain model) objects should not necessarily be exposed outside the core of the application, but should be considered a protected asset.

    You can use AutoMapper to automate the translation from business objects to data-transfer objects.

    0 讨论(0)
提交回复
热议问题