Best approach for building NHibernate DTO's

后端 未结 4 1863
夕颜
夕颜 2021-01-03 03:16

I\'m new to NHibernate (and ORMS) and trying to come to grips with the myriad of different options it presents. For reference, I\'m using Fluent NHibernate with seperate bus

4条回答
  •  温柔的废话
    2021-01-03 03:44

    The ISession is very inexpensive to open/close. The problem with keeping it open for too long is that the connection pool can't reuse the connection until it times out or what not. This could be a problem in a multiuser application.

    In your scenario I'd probably go for a service oriented approach to store retrieve data. meaning the DTO would only be used internally within the service boundaries. If you need to copy objects that look the same I suggest you have a look at AutoMapper which was created for this specific purpose. If you have a windows only or web only project then it's not a problem. It's when you mix. You can't handle the sessions the same way in a Windows app as in a Web app.

提交回复
热议问题