开发者

Get list of named queries in NHibernate

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


Configuration.NamedQueries has a list of named queries (it's an IDictionary, the key is the query name)

Of course, you'll need access to the Configuration instance, or save that list somewhere.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜