开发者

Best Practices for Windows Forms Apps with NHibernate

开发者 https://www.devze.com 2023-04-05 17:03 出处:网络
I\'ve been developing a windows forms application in C# (.net framework 4) and trying to apply NHibernate for data access. Our team has some experience using nhibernate (like mappings, configuration a

I've been developing a windows forms application in C# (.net framework 4) and trying to apply NHibernate for data access. Our team has some experience using nhibernate (like mappings, configuration and CRUD) in a web context and we have some questions about the use of nhibernate in windows context.

Could someone recommend an open-source project to study how to apply the nhibernate in the best way in windows forms apps ? (we mean, best way to do a CRUD in interf开发者_运维百科aces windows, using binding with nhibernate, ISession management in forms, etc...)


Have a look at http://msdn.microsoft.com/en-us/magazine/ee819139.aspx

The right solution depends on your needs of course but the key difference with using an ORM like NH in the web context as opposed to winforms is identifying when to open a session and when to close it. On the web, seasion per request is a popular architecture. On winforms, the answer is not so easy. If your app has many forms, session per form could be the answer. If it's a single-form-does-it-all, things get tricky. In the worse case, of course, you could demote to session per action ... but this is generally not recommended.

Other than that, there really shouldn't be any significant differences between the two.

0

精彩评论

暂无评论...
验证码 换一张
取 消