Hello boys and girls, I've been toying around with NH for a while and
now I am trying to figure out how to piece together a n-tier
application with it.  Here is my desired architecture:

Entities - Objects NH maps to
EntityManagers - Business objects that perform actions on the
entities, I suppose this will also own/query the ISession.
Service Layer - This is the application logic, could potentially be a
web service but doesn't have to be.
-------------------- NETWORK ----------------
ASP.NET Webforms - The front end will utilize DTOs to communicate with
the Service Layer.


While it makes sense to me that it's easy to get the data to flow to
the front end, I don't understand how to approach using NH for updates
on the way back?  For example lets say my front end called
Service.GetRows() which returned DTOs that eventually got bound to a
GridView.  The user decided to update one of the rows, I construct a
DTO and send it to the service, Service.UpdateRow(requestDto).  What
are my steps from here?  I imagine it would have to be something like
this:

1) Map the DTOs back to entities, but as the result these are not real
NH entities, because none of the proxies would be populated since the
objects weren't generated by the ISession to begin with?
2) Lets say I have now a Row entity.  Calling ISession.Update(row)
doesn't work because the ISession is not aware of the row.  Now I know
you can merge in (Lock?) objects that were generated from other
ISessions (detached), however in my case the objects weren't generated
by the ISession to begin with, they came from DTOs.  How do I overcome
this?  The obvious answer is I have to query the session to first
isolate the row I want to update, then update it.  Isn't this bad
practice though since I am making 2 database calls?


Please help me wrap my mind around this, thank you!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to