c# - Is it possible to do create a generic Session.QueryOver<T>? -


Is it possible to use some such NHibernate 3 outside of curiosity?

  Public IQueryable & LT; T & gt; FindAll & lt; T & gt; () {Return Session.Click on & lt; T & gt; (). List (). AsQueryable (); }  

I get a compilation error to say something like this ...

Type T should be a reference type so that it can be used as parameter T Could.

I was wondering if I can make an extension method for the session. To handle a common type.

I can change it like something like this

  return session Cret caratariya (typef (t)). List & lt; T & gt; (). Encocolable ();  

But the query was eager to use the API's features. any idea? It is possible that you are missing something special!

You are banning T :

  Public IQueryable & lt; T & gt; FindAll & lt; T & gt; () Where T: class {return session.click & lt; T & gt; (). List (). AsQueryable (); }  

where T: class defines that T should be a reference type. (As the compilation error was sought, it is explicitly limited to QueryOver context type). If obstacles are applied to it in a type parameter, then using this method, any common method will have to apply the same compulsions with a normal parameter.

To make a full overview of the common type parameter barriers, see.


Comments