Good idea. My mods can be found here: https://github.com/oillio/Castle.ActiveRecord
It uses a slightly modified NHibernate library based off of the 3.1.0 release. The only changes are minor refactorings to make some properties/methods more visible to external code. This fork provides two advancements: The complete implementation of the ActiveRecord ByteCode. This will provide session management for lazy proxies, collections, and properties. I believe it handles all lazy scenarios, please let me know if I missed any. A custom Linq Query Provider. The provider will manage the session when a query is executed. Therefore, you can create and execute queries outside of a Scope and move queries between Scopes without issue. The query will use whatever session is available when it is actually executed. Nick, For more information on configuring the ByteCode, please see the wiki: http://docs.castleproject.org/Active%20Record.The-ByteCode.ashx In addition to setting the ProxyFactory, as described in the wiki, you will also need to set the CollectionTypeFactory. In your configuration file, add the following line: <add key="collectiontype.factory_class" value="Castle.ActiveRecord.ByteCode.CollectionTypeFactory, Castle.ActiveRecord"/> An example config section would look something like this: <config> <add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/> <add key="dialect" value="NHibernate.Dialect.MsSql2000Dialect"/> <add key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/> <add key="connection.connection_string" value="Server=(local) \sqlexpress;initial catalog=test;Integrated Security=SSPI" /> <add key="proxyfactory.factory_class" value="Castle.ActiveRecord.ByteCode.ProxyFactoryFactory, Castle.ActiveRecord"/> <add key="collectiontype.factory_class" value="Castle.ActiveRecord.ByteCode.CollectionTypeFactory, Castle.ActiveRecord"/> <add key="query.factory_class" value="NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory, NHibernate"/ > </config> On Mar 29, 2:56 pm, Henry Conceição <[email protected]> wrote: > You should get a github account and have your mods published man. > Also, it would ease the review and merge of your changes ;-). > > On Mar 29, 4:40 pm, Dan Jasek <[email protected]> wrote: > > > > > They are doing quite a bit of updates over there, I don't think it > > would be a good idea to update AR midway through their release cycle. > > > If you are feeling adventurous, and want to compile your own NH and > > AR, I would be happy to post a patch. > > Grab a version of NHibernate after 3/26, the "Apply NH-2600" > > revision. Let me know if you do this, and I will put something > > together. > > > -Dan > > > On Mar 29, 1:11 pm, Nicholas Kilian <[email protected]> > > wrote: > > > > > Also, BTW - I got my required changes into NH for the ByteCode. So, > > > > next > > > > time the NH binaries are updated in AR, I will be able to add support for > > > lazy loading properties and collections outside of SessionScopes. > > > > You may have just become my favourite person. > > > > Which NH version are they out in? AR 3.0 RC is NH 3.1.0 ga. Possible we > > > could get that support out in final AR 3.0? > > > > - Nick > > > > -----Original Message----- > > > From: [email protected] > > > > [mailto:[email protected]] On Behalf Of Dan Jasek > > > Sent: 29 March 2011 07:06 PM > > > To: Castle Project Users > > > Subject: Re: Linq Queryable and sessions > > > > I think that would be much safer. This would throw an error if attempted > > > outside of a scope, right? I would have rather gotten an exception the > > > first time I tried to use queryable outside of a scope, instead of > > > stumbling > > > on the issue a few months later. > > > > I went ahead and wrote a slightly customized query provider that > > > creates/releases the session on execution. Of course it requires changes > > > to > > > the visibility of some methods in NH. Once I am sure it works, and I get > > > the changes into NH, and that code filters down to AR, I'll submit a > > > patch. > > > > Also, BTW - I got my required changes into NH for the ByteCode. So, next > > > time the NH binaries are updated in AR, I will be able to add support for > > > lazy loading properties and collections outside of SessionScopes. > > > > -Dan > > > > On Mar 28, 9:10 pm, Henry Conceição <[email protected]> wrote: > > > > Afaik, we can't have the same behavior (create & release session > > > > inside the method boundaries) of Create, Find, etc because we don't > > > > know when the query will be actually executed. So, the answer for your > > > > question is yes. > > > > > Now that you bring a light on this, I think that is better to replace > > > > the CreateSession by a lookup on the ThreadScopeInfo for a > > > > RegisteredScope. What do you think about it? > > > > > On Mar 25, 11:41 pm, Dan Jasek <[email protected]> wrote: > > > > > > Looking at the code, AnctiveRecordLinqBase.Queryable never releases > > > > > the ISession it creates. This is contrary to Create, Find, etc. > > > > > which all release their ISession after they are done with their work. > > > > > > Does this mean that a Queryable should always be used within a > > > > > SessionScope? > > > > > If you use it outside of a scope, will you leak ISessions? > > > > > > Thanks.- Hide quoted text - > > > > > - Show quoted text - > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Castle Project Users" group. > > > To post to this group, send email to > > > [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]. > > > For more options, visit this group > > > athttp://groups.google.com/group/castle-project-users?hl=en.-Hidequoted > > > text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
