k.c.
k.c.

Reputation: 1835

Query method for NHibernate with non-generic type parameter

We use NHibernate as our ORM. For the retrieval of most instances

session.Query<T>()

is just fine. How ever we have some instances where we want to specify the type during execution and pas it as a regular parameter something like:

session.Query(System.Type type)

Is this possible and if so what is the syntax?

Upvotes: 1

Views: 275

Answers (1)

Russ Cam
Russ Cam

Reputation: 125488

You can't specify the type like that with Session.Query<T>().

You can use Session.CreateCriteria(typeof(type)); and then use the Criteria API.

Upvotes: 2

Related Questions