views:

10

answers:

0

Hello,

I've started using nHibernate some time ago. But after some time I saw that something goes in wrong way. The application is written in MVP pattern. Whole application is 3-tier. I have a Repository layer, Service layer and MVP. Presenter is providing a SessionWrapper to services and then it's provided to repositories. So the whole session is open until all operations at service layer are not completed. This works but I wanted to this in better way by Conversation per Business Transaction - and here is the problem. I have many questions about that and can not find answers. After reading many blogs, posts, etc. I think now my DomainModel is wrong. So I would like to get Yours opinion abut that.

  1. Is that a good idea to have a repositories when using nHibernate or better use it directly in service layer?
  2. What You do if You have to load some summary object from DomainModel ex. you have Invoice with possitions and You want to show at View some things from it extended with some infos from possitions model. I have two DomainModels Document and DocumentSummary both are mapped to same table but DocumentSummary has only reading to it. Is that good approach or not? Maybe better load all things and reload it to some not mapped object?
  3. Next thing in this article is presented pattern for Conversation per Business Transaction but when You work with View model when and how session should be flushed on closing form? I would like to use this pattern but now I have too much question about it's implementation in good way. At this time I'm loading object by service layer from DB then mapping it with AutoMapper to View model. After operation in form is done I'm mapping it to Domain Model back and saving it by service layer. So question is how to automate it when model is rewrited from domain to presentation layer?

Thank's for answers I hope I will get some infos etc.