c# - Fluent NHibernate ISessionManager or equivilent -


i quite new fnh , nh world, gentle :p

i have created application using fnh data access works while not using lazy-loading, once enable lazy-loading goes pear shaped (as in, no sessions open when attempt access lazy-loaded properties etc).

the application layout have created thus-far has "database" singleton has various methods such save(), refer() , list().
when calling refer() session opened, data retrieved , session disposed; meaning there no session available when attempting access lazy-loaded property returned object. example: database.refer("username").person since person lazy-loaded , session has closed.

i have read castle has sessionmanager used scenario but, either it's late nights or lack of coffee, can't seem work out how hook fnh use manager as, in spirit of castle, defined in config files.

am missing something, or can not done? there other session managers (or more appropriate conventions) should at?

thanks on matter.

i don't think particular problem connected sessionmanager you've mentioned capable of starting new session , disposing whenever needed.

from can understand of post trying expose entity view (with lazy-loaded properties) - bad idea because leads nasty lazyinitializationexception(s).

you should consider making distinguishion between data-model , domain model. key concept has been described on blog:

ayende @ rahien http://ayende.com/blog/4054/nhibernate-query-only-properties

if writing simple 2-tier application not harm if micro-manage session in data-layer (but keep in mind not best solution).

i query fetches entity, seems me trying obtain data part of model - in case person. can lead serious problems n+1 selects:

what select n+1?

so in general think should focus more on how things structured in application instead of searching sessionmanager not resolve of problems.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -