获取 NHibernate 中的命名查询列表
我的 NHibernate 项目中有十几个左右的命名查询,我想在单元测试中针对测试数据库执行它们,以确保语法仍然匹配不断变化的域/数据库模型。目前,我对获取并执行查询的每个命名查询都有一个单元测试,例如:
IQuery query = session.GetNamedQuery("GetPersonSummaries");
var personSummaryArray = query.List();
Assert.That(personSummaryArray, Is.Not.Null);
这工作正常,但我希望有一个单元测试可以循环所有命名查询并执行它们。有没有办法发现所有可用的命名查询?
谢谢
担
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Configuration.NamedQueries
有一个命名查询列表(它是一个 IDictionary,键是查询名称)当然,您需要访问
Configuration
实例,或者保存该列表在某处。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.