using (Fluent) NHibernate with StructureMap (or any IoCC)

后端 未结 2 1421
时光取名叫无心
时光取名叫无心 2021-02-04 20:29

On my quest to learn NHibernate I have reached the next hurdle; how should I go about integrating it with StructureMap?

Although code examples are very welcome, I\'m mor

2条回答
  •  执念已碎
    2021-02-04 20:49

    I've not used structure map but maybee I can still help guide you in the right direction. Fluent nHibernate is awsome good choice over the hbm files.

    As for the http request, you do not need to ensure that you close the session when the http request ends. If you don't you'll end up leaking nHibernate session. I'm not sure if structure map will handle this for you, what I've done is I have an http module which closes the session.

    One thing to note though that bite me, is that you will make to sure you wrap all your data access in a transaction and ensure nHibernate actually commits its changes. If you do this as part of your session close, you could miss the chance to handle errors. I'm curious to hear what you ended up having to do to get this workign.

提交回复
热议问题