LinqExtensionMethods.Query<T> implements wrong NhQueryable<T>

Description

According to this post http://groups.google.com/group/castle-project-devel/browse_thread/thread/ac90148a8d4c8477

It seems it's a bug in NHibernate LinqExtensionMethods implementation. If
you take a look at LinqExtensionMethods.Query<T>(this ISession)
implementation in NHibernate souce code, it's currently implemented like
this:

public static IQueryable<T> Query<T>(this ISession session)
{
return new NhQueryable<T>(session as ISessionImplementor);
}

when it should be implemented like this:

public static IQueryable<T> Query<T>(this ISession session)
{
return new NhQueryable<T>(session.GetSessionImplementation());
}

The explanation is that in NHibernate SessionImpl, it inherits from
ISessionImplementor, while in NHibernateFacility SessionDelegate, it doesn't
inherit from ISessionImplementor. That's why when SessionDelegate cast back
to ISessionImplementor, it became null.

Environment

None

Activity

Show:

Fabio Maulo 
July 30, 2011 at 2:11 PM

Closed after final release of NH3.2.0GA

Maximilian Haru Raditya 
April 6, 2011 at 8:41 AM

Thanks, Patrick! It's such a quick response .

Patrick Earl 
April 6, 2011 at 8:16 AM

I also searched for any other cases where this sort of cast was present and found none.

Kenneth Siewers Møller 
April 6, 2011 at 7:19 AM

This applies to both Query<T>(this ISession session) as well as Query<T>(this IStatelessSession session).

Kenneth Siewers Møller 
April 5, 2011 at 11:59 PM

As a matter of fact, the remarks in the documentations actually states the following about GetSessionImplementation():

"This method is provided in order to get the NHibernate implementation of the session from wrapper implementions. Implementors of the ISession interface should return the NHibernate implementation of this method."

So I believe this is quite a serious bug, as any wrapper basically won't work.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created April 5, 2011 at 11:47 PM
Updated July 30, 2011 at 2:11 PM
Resolved April 6, 2011 at 8:13 AM
Who's Looking?