protected override Expression VisitMethodCall(MethodCallExpression expr)
        {
            Type = BinaryCriterionType.Criteria;

            //TODO: don't hardcode this alias 'sub'
            Criteria = DetachedCriteria.ForEntityName(rootCriteria.GetEntityOrClassName(), "sub");

            EntityExpression rootEntity = EntityExpressionVisitor.RootEntity(expr);

            if (rootEntity != null)
            {
                string identifierName = rootEntity.MetaData.IdentifierPropertyName;
                Criteria.Add(Restrictions.EqProperty(rootCriteria.Alias + "." + identifierName, "sub." + identifierName));
            }

            var visitor = new RootVisitor(Criteria.Adapt(session), session, false);

            visitor.Visit(expr);

            return(expr);
        }