Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning NHibernate mapping classes from WCF services

Tags:

wcf

nhibernate

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.

When the NHibernate POCO is returned from the service are all the objects in the object graph serialized? If so, is there a way to change it?

I'm also thinking of not returning the NHibernate POCO and instead return an object with only the essential information.

What do you do in these cases?

like image 857
Megacan Avatar asked Dec 06 '25 06:12

Megacan


1 Answers

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.

like image 86
yfeldblum Avatar answered Dec 07 '25 21:12

yfeldblum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!