1

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

Noah
  • 15,080
  • 13
  • 104
  • 148

1 Answers1

1

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

Firo
  • 30,626
  • 4
  • 55
  • 94
  • Is there an easy way to see the entire sql that will be generated, including the tables, etc? – Noah Aug 19 '11 at 18:10
  • see http://www.davesquared.net/2008/01/viewing-sql-generated-by-nhibernate.html for logging sql – Firo Aug 20 '11 at 20:14
  • Yes, I know about the logging options, I was looking for something that would display directly in the debugger – Noah Aug 20 '11 at 23:09