如何使用 VisualStudio 10 调试器检查底层 nHibernate (3.1) 标准文本
在 Windows 下,我的代码类似于以下内容:
var active_ids = QueryOver.Of<Members>()
.Where(m => m.HasAccess);
我发现如果我在此行之后中断调试器并输入
?active_ids.criteria 显示以下内容:
{IsApproved = True}
并且
var namematch = Restrictions.Disjunction();
namematch.Add(Restrictions.Where<Members>(m => m.FirstName.IsInsensitiveLike(name.AsStartsWith())));
namematch.Add(Restrictions.Where<Members>(m => m.LastName.IsInsensitiveLike(name.AsStartsWith())));
namematch.Add(Restrictions.Where<Members>(m => m.LastName.IsInsensitiveLike(("-" + name).AsContains())));
我发现如果我在此行之后中断调试器并输入
?namematch.criteria 显示以下内容:
Count = 3
[0]: {FirstName ilike bak%}
[1]: {LastName ilike bak%}
[2]: {LastName ilike %-bak%}
但是,当我有一个非常复杂的查询时,类似于:
var matchQuery = session.QueryOver<Member_Graph>()
.WithSubquery.WhereProperty(vg => vg.MemberId).In(memberlist)
.Where(approved_members)
.JoinQueryOver<Trainers_Graph>(t => t.trainers)
.Where(namematch)
.Select(t => t.trainers);
但是,当我输入 ?matchQuery
'NHibernate...' 时不包含“criteria”的定义,并且找不到接受类型...的第一个参数的扩展方法“criteria”(您是否缺少 using 指令或程序集引用?)
因此,使用 Visual Studio 调试器,如何才能 找到我列出了完整的标准nHibernate 为 matchQuery 生成
Under Windows I have code similar to the following:
var active_ids = QueryOver.Of<Members>()
.Where(m => m.HasAccess);
I have found that if I break the debugger after this line and type
?active_ids.criteria the following is displayed:
{IsApproved = True}
and
var namematch = Restrictions.Disjunction();
namematch.Add(Restrictions.Where<Members>(m => m.FirstName.IsInsensitiveLike(name.AsStartsWith())));
namematch.Add(Restrictions.Where<Members>(m => m.LastName.IsInsensitiveLike(name.AsStartsWith())));
namematch.Add(Restrictions.Where<Members>(m => m.LastName.IsInsensitiveLike(("-" + name).AsContains())));
I have found that if I break the debugger after this line and type
?namematch.criteria the following is displayed:
Count = 3
[0]: {FirstName ilike bak%}
[1]: {LastName ilike bak%}
[2]: {LastName ilike %-bak%}
However, when I have a very complicated query, similar to:
var matchQuery = session.QueryOver<Member_Graph>()
.WithSubquery.WhereProperty(vg => vg.MemberId).In(memberlist)
.Where(approved_members)
.JoinQueryOver<Trainers_Graph>(t => t.trainers)
.Where(namematch)
.Select(t => t.trainers);
However, when I type ?matchQuery
'NHibernate...' does not contain a definition for 'criteria' and no extension method 'criteria' accepting a first argument of type ... could be found (are you missing a using directive or an assembly reference?)
So, using the Visual Studio Debugger, how can I list the full criteria that nHibernate generates for matchQuery
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
session.QueryOver() 只是 ICriteria 的包装,它具有显示为字符串的良好能力。要访问底层条件,请使用
matchQuery.RootCriteria
session.QueryOver() is just a wrapper for a ICriteria which has the nice ability to be displayed as a string. To access the underlying Criteria use
matchQuery.RootCriteria