Пример #1
0
        public override void VisitSelectClause(SelectClause selectClause, QueryModel queryModel)
        {
            CurrentEvaluationType = selectClause.GetOutputDataInfo();

            switch (_queryMode)
            {
            case QueryMode.Delete:
                VisitDeleteClause(selectClause.Selector);
                return;

            case QueryMode.Update:
            case QueryMode.UpdateVersioned:
                VisitUpdateClause(selectClause.Selector);
                return;

            case QueryMode.Insert:
                VisitInsertClause(selectClause.Selector);
                return;
            }

            //This is a standard select query

            var visitor = new SelectClauseVisitor(typeof(object[]), VisitorParameters);

            visitor.VisitSelector(selectClause.Selector);

            if (visitor.ProjectionExpression != null)
            {
                _hqlTree.AddItemTransformer(visitor.ProjectionExpression);
            }

            _hqlTree.AddSelectClause(_hqlTree.TreeBuilder.Select(visitor.GetHqlNodes()));

            base.VisitSelectClause(selectClause, queryModel);
        }
Пример #2
0
        private void VisitDeleteClause(Expression expression)
        {
            // We only need to check there is no unexpected select, for avoiding silently ignoring them.
            var visitor = new SelectClauseVisitor(typeof(object[]), VisitorParameters);

            visitor.VisitSelector(expression);

            if (visitor.ProjectionExpression != null)
            {
                throw new InvalidOperationException("Delete is not allowed on projections.");
            }
        }