Get list of named queries in NHibernate

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2010-06-05T14:16:01Z Indexed on 2010/06/05 14:22 UTC
Read the original article Hit count: 303

I have a dozen or so named queries in my NHibernate project and I want to execute them against a test database in unit tests to make sure the syntax still matches the changing domain/database model. Currently I have a unit test for each named query where I get and execute the query, for example:

IQuery query = session.GetNamedQuery("GetPersonSummaries");
var personSummaryArray = query.List();
Assert.That(personSummaryArray, Is.Not.Null);

This works fine, but I would like to have one unit test that loops thru all of the named queries and executes them. Is there a way to discover all of the available named queries?

Thanks
Dan

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about nhibernate