tags:

views:

806

answers:

2

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?

+4  A: 

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.

Justice
I hadn't heard if this before. Looks like exactly what I need. thanks
Megacan
Well, it's new and still under heavy development. Cheers!
Justice
A: 

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.

Andy White