如何使用 VisualStudio 10 调试器检查底层 nHibernate (3.1) 标准文本

发布于 2024-11-30 05:30:52 字数 1408 浏览 1 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷弦 2024-12-07 05:30:53

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文