eka808
eka808

Reputation: 2317

Define a list type into a variable

Hello everybody I have a LINQ declaration like this :

var query = from foo in NHibernate_Helper.session.Linq<TheType>() select foo;

Is it possible to store TheType into a variable to dynamically define this one ?

Thank you by advance

Upvotes: 2

Views: 228

Answers (2)

codeConcussion
codeConcussion

Reputation: 12938

This doesn't do exactly what you asked, but can you just make your method generic?

public IEnumerable<T> GetSomething<T>()
{
    return (from foo in NHibernate_Helper.session.Linq<T>() select foo);
}
...
GetSomething<TheType>();

Upvotes: 3

Jamiec
Jamiec

Reputation: 136174

No, generic types must be known at compile time.

Upvotes: -1

Related Questions