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 at http://groups.google.com/group/castle-project-users?hl=en.
