public object TranslateExpression(Expression expression)
        {
            if (_Log.IsDebugEnabled)
                _Log.DebugFormat("Translating expression: {0}", expression);

            expression = Evaluator.PartialEval(expression);
            expression = new BinaryBooleanReducer().Visit(expression);

            var addedAlias = new Dictionary<string, IList<string>>();
            expression = new AssociationVisitor((ISessionFactoryImplementor)session.SessionFactory, addedAlias).Visit(expression);

            expression = new InheritanceVisitor().Visit(expression);
            expression = CollectionAliasVisitor.AssignCollectionAccessAliases(expression);
            expression = new PropertyToMethodVisitor().Visit(expression);
            expression = new BinaryExpressionOrderer().Visit(expression);

            if (_Log.IsDebugEnabled)
                _Log.DebugFormat("Optimized expression: {0}", expression);

            var translator = new NHibernateQueryTranslator(session, entityName);

            return this.rootCriteria == null ?
                translator.Translate(expression, this.queryOptions) :
                translator.Translate(expression, (ICriteria)this.rootCriteria.Clone());
        }
		public object TranslateExpression(Expression expression)
		{
			expression = Evaluator.PartialEval(expression);
			expression = new BinaryBooleanReducer().Visit(expression);
			expression = new AssociationVisitor((ISessionFactoryImplementor)_session.SessionFactory).Visit(expression);
			expression = new InheritanceVisitor().Visit(expression);
			expression = CollectionAliasVisitor.AssignCollectionAccessAliases(expression);
			expression = new PropertyToMethodVisitor().Visit(expression);
			expression = new BinaryExpressionOrderer().Visit(expression);

			NHibernateQueryTranslator translator = new NHibernateQueryTranslator(_session,entityName);
			return translator.Translate(expression, this.queryOptions);
		}
Esempio n. 3
0
        public object TranslateExpression(Expression expression, bool isExecute)
        {
            expression = Evaluator.PartialEval(expression);
            expression = new BinaryBooleanReducer().Visit(expression);
            expression = new AssociationVisitor((ISessionFactoryImplementor)_session.SessionFactory).Visit(expression);
            expression = new InheritanceVisitor().Visit(expression);
            expression = CollectionAliasVisitor.AssignCollectionAccessAliases(expression);
            expression = new PropertyToMethodVisitor().Visit(expression);
            expression = new BinaryExpressionOrderer().Visit(expression);

            QueryTranslator translator = new QueryTranslator(_session, entityName);
            this.rootCriteria = null;
            rootCriteria = translator.Translate(expression, this.queryOptions);

            VKeCRMRootVisitor visitor = new VKeCRMRootVisitor(rootCriteria, _session, true);
            visitor.Visit(expression);
            if (!isExecute)
            {
                return rootCriteria;
            }
            return visitor.Results;
        }