From: Dan J. (JIRA) <nh...@gm...> - 2011-04-11 22:46:13
|
[ http://216.121.112.228/browse/NH-2611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20891#action_20891 ] Dan Jasek commented on NH-2611: ------------------------------- I need to hook into the Execute operation on the Provider. ActiveRecord currently opens a session when the Linq query is defined, but it never releases it. This is because it can't tell when the query will actually be called and the session will be used. The easiest solution I found was to get the session when the Linq query was actually executed, and release it immediately afterward. This way, the query can be created detached, moved between SessionScopes, etc with no problem. It will simply use the session available when the query is actually executed. To do that, I need to tweak the NH provider a bit. I could create my own Queryable/Provider, but that causes issues with extension methods and other references (Futures) and it looks like I would need to take a dependency on Remotion in ActiveRecord. What do you mean by, "Not enough. We are casting it for Future..." I saw the way Linq queries can be turned into Futures, but I did not see an issue with what I am doing. This is why I set ExecuteFuture to virtual as well. If you are interested The thread about this on the AR group is here: http://groups.google.com/group/castle-project-users/browse_frm/thread/be987e3084dad707 And the custom provider I wrote based off of these edits can be found here: https://github.com/oillio/Castle.ActiveRecord/blob/master/src/Castle.ActiveRecord/Framework/ARQueryProvider.cs > Allow injectable/inheritance of Linq query provider > --------------------------------------------------- > > Key: NH-2611 > URL: http://216.121.112.228/browse/NH-2611 > Project: NHibernate > Issue Type: New Feature > Components: Linq Provider > Affects Versions: 3.1.0 > Reporter: Dan Jasek > Priority: Minor > Attachments: LinqVisibility.patch > > > I have one final request for relaxing incaptulation in NH. These changes will allow me to create a custom Query Provider for ActiveRecord which properly manages the session lifecycle when executig a linq query. > The applied patch makes a couple of methods in Linq.NhQueryProvider virtual or protected. > It also moves the access of the internal session from PrepareQuery to Execute. If you can't make this change, could you make SetParameters protected instead? > Finally, it adds a constructor to Linq.NhQueryable which will allow me to insert my custom query provider when creating a Query. > Thanks. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |