tag:blogger.com,1999:blog-6582375716637820002.post9112893876655324664..comments2024-02-15T21:08:00.355-07:00Comments on Vadim's Dev Blog: NHibernate unit of work in MVC using Ninject (part 2)Vadimhttp://www.blogger.com/profile/15179930234192295354noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6582375716637820002.post-34399039428341003492012-04-19T08:11:34.415-06:002012-04-19T08:11:34.415-06:00The presentation only needs to know if whatever it...The presentation only needs to know if whatever it is doing needs to be encapsulated in a unit of work. It's technology agnostic. You're right though, it's not 100% optimal.Vadimhttps://www.blogger.com/profile/15179930234192295354noreply@blogger.comtag:blogger.com,1999:blog-6582375716637820002.post-60014284741266751992012-04-16T23:45:05.651-06:002012-04-16T23:45:05.651-06:00Nice solution, but I do see a violation of separat...Nice solution, but I do see a violation of separation of concerns. The presentation layer has to know details about database persistence; but I do think this could be a small sacrifice for what you are getting.Danhttps://www.blogger.com/profile/03793004308166139676noreply@blogger.comtag:blogger.com,1999:blog-6582375716637820002.post-76646158901278351412011-06-15T08:44:59.896-06:002011-06-15T08:44:59.896-06:00@Todd, you can have your UnitOfWorkAttribute imple...@Todd, you can have your UnitOfWorkAttribute implement the IExceptionFilter. This will allow you to implement the OnException method where you can roll back your transaction.Vadimhttps://www.blogger.com/profile/15179930234192295354noreply@blogger.comtag:blogger.com,1999:blog-6582375716637820002.post-61315083709123559672011-06-14T16:30:28.120-06:002011-06-14T16:30:28.120-06:00Very nice, this clears up some things regarding wh...Very nice, this clears up some things regarding why my BeginRequest/EndRequest solution isn't working. Just curious, do you have a recommended way to deal with rolling back open transactions when an unhandled exception occurs elsewhere in the application?Toddhttps://www.blogger.com/profile/07905433636808611661noreply@blogger.comtag:blogger.com,1999:blog-6582375716637820002.post-7111718541531838132011-05-05T08:23:32.800-06:002011-05-05T08:23:32.800-06:00@pghtech I'm using MVC2 and the Ninject.Web.Mv...@pghtech I'm using MVC2 and the Ninject.Web.Mvc project, for that version, has its own ControllerFactory that injects any dependencies into the filters. If you note there is a InjectAttribute decorating the UnitOfWork property. That tells Ninject that it needs to inject that property when creating the attribute. <br />If you're using MVC3 here's a write up on how to use StructureMap to create a FilterProvider.Vadimhttps://www.blogger.com/profile/15179930234192295354noreply@blogger.comtag:blogger.com,1999:blog-6582375716637820002.post-2501313708499163352011-05-04T08:09:58.509-06:002011-05-04T08:09:58.509-06:00Vadim: How are you injecting the UnitOfWork prope...Vadim: How are you injecting the UnitOfWork property on the attribute? I am using StructureMap (which I know you aren't), but I am finding problems in doing so.Anonymousnoreply@blogger.com