Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top