Also see: http://stackoverflow.com/questions/5549404/nhibernate-3-1-0-4000-nullreferenceexception-using-query-and-nhibernate-facil
2011/4/6 Kenneth Siewers Møller <[email protected]> > I just did a quick extension method that works around the Query<T> API. I > did the same implementation, but instead of calling "session as > ISessionImplementor" I did "session.GetSessionImplementation()" and it > works... > This is a bug in NHibernate. Even the docs says that the method > GetSessionImplementation() is for use with wrappers, so I can't really argue > that this should be a bug in the facility. > > > Kenneth > > > 2011/4/6 Henry Conceição <[email protected]> > >> It looks like a bug in the nhfacility. Can you please open a ticket >> for it? I'll take o look later this week. Btw, a test case reproducing >> the issue would be pretty handy. >> >> Cheers, >> Henry Conceição >> >> >> >> On Wed, Apr 6, 2011 at 2:09 AM, Maximilian Raditya <[email protected]> >> wrote: >> > 2011/4/6 Kenneth Siewers Møller <[email protected]> >> >> >> >> The NHibernateFacility version 2.0 RC breaks the Query<> API of >> >> NHibernate. I can do QueryOver<> but Query<> throws a >> >> NullReferenceException. >> > >> > 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. >> > >> > I think this bug should be reported in here: http://jira.nhforge.org. >> > >> > >> > >> > -- >> > Regards, >> > >> > Maximilian Haru Raditya >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Castle Project Development List" 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-devel?hl=en. >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Castle Project Development List" 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-devel?hl=en. >> >> > > > -- > Med venlig hilsen / Kind regards > Kenneth Siewers Møller > > -- Med venlig hilsen / Kind regards Kenneth Siewers Møller -- You received this message because you are subscribed to the Google Groups "Castle Project Development List" 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-devel?hl=en.
