Skip to content

RowCount not working with JoinEntityAlias #1680

@adigourdi

Description

@adigourdi

When using JoinEntityAlias with queryOver.RowCount() or queryOver.ToRowCountQuery() throws an error

Exception thrown: 'NHibernate.QueryException' in NHibernate.dll
An exception of type 'NHibernate.QueryException' occurred in NHibernate.dll but was not handled in user code
could not resolve property: child2 of: Namespace.To.Child1

Example

Let's say I have 3 classes Parent, Child1, and Child2.
Both childs have a property Parent referencing Parent class
And I'd like to join between Child1 and Child2 using the parent property

Child1 child1 = null;
Child2 child2 = null;

var query = session
    .QueryOver(() => child1)
    .JoinEntityAlias(
        () => child2,
        () => child2.Parent.Id == child1.Parent.Id,
        NHibernate.SqlCommand.JoinType.InnerJoin
    )
    ;

// [ ... ] // ommitted code for brevity

query // pagination
    .Skip(20)
    .take(10)
    ;

query.List(); // returns the correct list paginated
query.RowCount(); // throws the error above
query.ToRowCountQuery().SingleOrDefault<int>(); // throws the same error

Notes

  1. I'm using Future for this, the same issue occurs
  2. both RowCount() and ToRowCountQuery() work fine with JoinAlias
  3. I haven't tested JoinEntityQueryOver(), but I believe the same issue applies

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions