Alex Burtsev
Alex Burtsev

Reputation: 12668

NHibernate QueryOver with subquery using parent (root) alias = could not resolve property exception

Entity root = null;
var query = Session.QueryOver(() => root);
var subQuery = QueryOver.Of<Entity>();
subQuery.Where((x) => x.Id == root.Id).Select(Projections.RowCount());
query.WithSubquery.WhereValue(0).Eq(subQuery);
query.List();

This doesn't work. I don't get it. I'v seen similar examples that people claim to work. Is it NH 4.04 bug or i'm doind something wrong?

NHibernate.QueryException: could not resolve property: root of: Entity

Upvotes: 1

Views: 422

Answers (1)

Alex Burtsev
Alex Burtsev

Reputation: 12668

I Figured this out. The exception mentioned, is caught inside NH, and it doesn't break the query. I was debuging code in Visual Studio with enabled "stop on thrown exception" option. And thought I had "only my code" option switched on, for some strange reason exception from NH are shown.

My collegue pointed out that line of code with caught exceptions is highlighted in green, and uncaught are yellow.

Upvotes: 1

Related Questions