NHibernate DTO with deep object graph

I am writing a WPF application for a smart client using MVVM that interacts with a WCF service layer containing business logic and domain objects that NHibernate uses to manage persistence. We control both sides of the wire.

I am currently working on creating a screen for editing product details, it has a tab control with each tab representing some aspects of the product such as Basics, Product Class, Container Type, etc. Eventually there will probably be at least 5 of these tabs.

So far I have been working on converting simple domain objects to DTOs using SetResultTransformer and it works very well.

Now when I get to a more complex object, I get a little stuck. I would like to return a rendered DTO containing basic product details, categories and classes. As far as categories and classes are concerned, I would not want to return every property of a domain object.

Questions:
1) How are people going to create DTOs where there are multiple many collections returned, like in this example?
  2) Are there any doubts that the DTO is getting too big?
3) When sending DTOs back to the back end, is it better to send the same type of DTO with updated values, or some other more command oriented DTO?

Thanks for any help

Alex

+3


source to share


2 answers


We are currently using quite large DTOs and it works really well. NHibernate does a lot of lazy loading, so it helps with large objects.

We use packages to relate to each other, they are lazy loaded and work really well.

Depending on the type of application, lazy loading can be a problem. We had some problems with our rich client application with large DTOs, but with some planning and sound architecture, it works very well.



I don't know if big DTOs are really problems with NHibernate, but we have no problems so far.

We ship the whole object back and forth and everything goes well. NHibernate only updates changed fields, which is really nice.

I would not serialize NHIbernate objects via web services or anything like that (I don't know the WCF service layer and how it interacts with your application). If I pass data through web services, I create new data objects and populate them neatly, move them back and forth, and update NHibernate objects with them.

+1


source


Have you tried Automapper? I am doing all my DTO mappings with Automapper and it works like a charm. Have a look at automapper . I'm sure you will like it.



+1


source