private object TranslateInternal(LinqExpression expression)
        {
            Visit(expression); //ensure criteria

            var visitor = new RootVisitor(rootCriteria, session, true);
            visitor.Visit(expression);
            return visitor.Results;
        }
        private object TranslateInternal(LinqExpression expression)
        {
            Visit(expression);             //ensure criteria

            var visitor = new RootVisitor(rootCriteria, session, true);

            visitor.Visit(expression);
            return(visitor.Results);
        }
		public virtual object Translate(LinqExpression expression, QueryOptions queryOptions)
		{
			this.rootCriteria = null;
			this.options = queryOptions;

			Visit(expression); //ensure criteria

			var visitor = new RootVisitor(rootCriteria, session, true);
			visitor.Visit(expression);
			return visitor.Results;
		}
        private object TranslateInternal(LinqExpression expression)
        {
            try
            {
                Visit(expression); //ensure criteria

                var visitor = new RootVisitor(rootCriteria, session, true);
                visitor.Visit(expression);

                if (_Log.IsDebugEnabled)
                    _Log.DebugFormat("Translated Criteria: {0}", rootCriteria.ToString());

                return visitor.Results;
            }
            catch (Exception ex)
            {
                var tmp = rootCriteria != null ? rootCriteria.ToString() : "{null}";
                _Log.ErrorFormat("Linq translation failed, current criteria: {0}", tmp);
                throw;
            }
        }
        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);
        }
        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;
        }