2011-01-12 1 views
24


Quando provo a compilare il seguente codiceNHibernate - Dove ISession.Query <T>() si trova

using System; 
using System.Collections.Generic; 
using System.Reflection; 
using System.Linq; 
using NHibernate; 

namespace NewNHTest 
{ 
    class A 
    { } 

    class Program 
    { 
     static void Main(string[] args) 
     { 
      ISession session; 
      var q = session.Query<A>(); 
     } 
    } 
} 

ottengo il seguente errore:

'NHibernate.ISession' does not contain a definition for 'Query' and no extension method 'Query' accepting a first argument of type 'NHibernate.ISession' could be found (are you missing a using directive or an assembly reference?) 

versione NHibernate.dll è 3.0 .0.4000.
La versione .Net del progetto è 3.5.

Cosa sto sbagliando?
Grazie per il vostro aiuto!

risposta

48
ISession.Query 

è nuovo di NHibernate 3 ed è un metodo di estensione. Prova

using NHibernate.Linq 

e dovrebbe essere risolto bene.