简体   繁体   中英

Method not found: 'System.Linq.IQueryable`1<!!0> NHibernate.Linq.LinqExtensionMethods.Query(NHibernate.IStatelessSession)'

I have a problem when upgrading NHibernate from 4.1.2 to 5.2.3 and Target Framework from 4.5 to 4.6.2 (to compatible with NH 5.x). The problem occurs when I execute the query using LINQ (it worked well before):

service.Query.Where(p => p.Approved).FirstOrDefault();

This is detail message exception:

Method not found: 'System.Linq.IQueryable`1 NHibernate.Linq.LinqExtensionMethods.Query(NHibernate.IStatelessSession)'.

I notice when I call service.Query, the system will throw an exception:

'service.Query' threw an exception of type 'System.MissingMethodException'

What did I miss?

Your app is still trying to call old extension Query method which was removed in NHibernate 5. Query is IStatelessSession/ISession interface method since NHibernate 5.

Exception you see means that your app is not properly recompiled with new NHibernate dlls. Make sure that all your projects reference new dlls (or nuget package) and you have no compilation errors (possible case - you run last successful build before upgrade but with newer dlls).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM