Beispiel #1
0
        public static HqlBooleanExpression AsBooleanExpression(this HqlTreeNode node)
        {
            if (node is HqlDot)
            {
                return(new HqlBooleanDot(node.Factory, (HqlDot)node));
            }

            // TODO - nice error handling if cast fails
            return((HqlBooleanExpression)node);
        }
Beispiel #2
0
 internal void AddChild(HqlTreeNode child)
 {
     if (child is HqlExpressionSubTreeHolder)
     {
         AddChildren(child.Children);
     }
     else
     {
         _children.Add(child);
         _node.AddChild(child.AstNode);
     }
 }
Beispiel #3
0
 internal void AddChild(HqlTreeNode child)
 {
     if (child is HqlDistinctHolder)
     {
         AddChildren(child.Children);
     }
     else
     {
         _children.Add(child);
         _node.AddChild(child.AstNode);
     }
 }
Beispiel #4
0
        internal static HqlExpression ToArithmeticExpression(this HqlTreeNode node)
        {
            var hqlBooleanExpression = node as HqlBooleanExpression;

            if (hqlBooleanExpression != null)
            {
                var builder = new HqlTreeBuilder();

                return(builder.Case(new[] { builder.When(hqlBooleanExpression, builder.True()) }, builder.False()));
            }

            return((HqlExpression)node);
        }
Beispiel #5
0
        public static HqlBooleanExpression AsBooleanExpression(this HqlTreeNode node)
        {
            var hqlDot = node as HqlDot;

            if (hqlDot != null)
            {
                return(new HqlBooleanDot(hqlDot.Factory, hqlDot));
            }
            var hqlBooleanExpression = node as HqlBooleanExpression;

            if (hqlBooleanExpression != null)
            {
                return(hqlBooleanExpression);
            }

            // TODO - nice error handling if cast fails
            throw new NotSupportedException();
        }
Beispiel #6
0
        public static HqlBooleanExpression ToBooleanExpression(this HqlTreeNode node)
        {
            var hqlDot = node as HqlDot;

            if (hqlDot != null)
            {
                return(new HqlBooleanDot(hqlDot.Factory, hqlDot));
            }
            var hqlBooleanExpression = node as HqlBooleanExpression;

            if (hqlBooleanExpression != null)
            {
                return(hqlBooleanExpression);
            }

            var builder = new HqlTreeBuilder();

            return(builder.Equality(node.AsExpression(), builder.True()));
        }
Beispiel #7
0
 public HqlJoin(IASTFactory factory, HqlTreeNode expression, HqlAlias @alias) : base(HqlSqlWalker.JOIN, "join", factory, expression, @alias)
 {
 }
		private void ExecuteAddOrderBy(HqlTreeNode orderBy)
		{
			if (orderBy == null)
				return;

			if (!_root.NodesPreOrder.OfType<HqlOrderBy>().Any())
				_root.As<HqlQuery>().AddChild(orderBy);
		}
 public void AddFromClause(HqlTreeNode from)
 {
     root.NodesPreOrder.Where(n => n is HqlFrom).First().AddChild(from);
 }
 public void AddSelectClause(HqlTreeNode select)
 {
     root.NodesPreOrder.Where(n => n is HqlSelectFrom).First().AddChild(select);
 }
Beispiel #11
0
 public void AddChild(int index, HqlTreeNode node)
 {
     _children.Insert(index, node);
     _node.InsertChild(index, node.AstNode);
 }
Beispiel #12
0
 public HqlOrderBy(IASTFactory factory, HqlTreeNode expression, HqlDirection hqlDirection)
     : base(HqlSqlWalker.ORDER, "", factory, expression,
            hqlDirection == HqlDirection.Ascending ?
                 (HqlTreeNode)new HqlDirectionAscending(factory) : (HqlTreeNode)new HqlDirectionDescending(factory))
 {
 }
Beispiel #13
0
 public HqlCount(IASTFactory factory, HqlTreeNode child)
     : base(HqlSqlWalker.COUNT, "count", factory, child)
 {
 }
Beispiel #14
0
 public static HqlExpression AsExpression(this HqlTreeNode node)
 {
     // TODO - nice error handling if cast fails
     return((HqlExpression)node);
 }
Beispiel #15
0
 public HqlAnd(IASTFactory factory, HqlTreeNode left, HqlTreeNode right) : base(HqlSqlWalker.AND, "and", factory, left, right)
 {
 }
Beispiel #16
0
 public HqlMin(IASTFactory factory, HqlTreeNode expression)
     : base(HqlSqlWalker.AGGREGATE, "min", factory, expression)
 {
 }
Beispiel #17
0
 public HqlAverage(IASTFactory factory, HqlTreeNode expression) : base(HqlSqlWalker.AGGREGATE, "avg", factory, expression)
 {
 }
Beispiel #18
0
 public HqlCast(IASTFactory factory, HqlTreeNode expression, System.Type type) : base(HqlSqlWalker.METHOD_CALL, "method", factory)
 {
     AddChild(new HqlIdent(factory, "cast"));
     AddChild(new HqlExpressionList(factory, expression, new HqlIdent(factory, type)));
 }
Beispiel #19
0
 public HqlAs(IASTFactory factory, HqlTreeNode expression, System.Type type) : base(HqlSqlWalker.AS, "as", factory, expression)
 {
     switch (System.Type.GetTypeCode(type))
     {
         case TypeCode.Int32:
             AddChild(new HqlIdent(factory, "integer"));
             break;
         default:
             throw new InvalidOperationException();
     }
 }
Beispiel #20
0
 public HqlWhere(IASTFactory factory, HqlTreeNode expression)
     : base(HqlSqlWalker.WHERE, "where", factory, expression)
 {
 }
Beispiel #21
0
 internal void AddChild(HqlTreeNode child)
 {
     _children.Add(child);
     _node.AddChild(child.AstNode);
 }
		public HqlRange Range(HqlTreeNode ident, HqlAlias alias)
		{
			return new HqlRange(_factory, ident, alias);
		}
		public HqlExpressionSubTreeHolder(IASTFactory factory, HqlTreeNode[] children) : base(int.MinValue, "expression sub-tree holder", factory, children)
		{
		}
		public HqlIn(IASTFactory factory, HqlExpression itemExpression, HqlTreeNode source)
			: base(HqlSqlWalker.IN, "in", factory, itemExpression)
		{
			AddChild(new HqlInList(factory, source));
		}
		public void AddFromClause(HqlTreeNode from)
		{
			_root.NodesPreOrder.OfType<HqlFrom>().First().AddChild(from);
		}
		public void AddSelectClause(HqlTreeNode select)
		{
			_root.NodesPreOrder.OfType<HqlSelectFrom>().First().AddChild(select);
		}
Beispiel #27
0
 public HqlIn(IASTFactory factory, HqlExpression itemExpression, HqlTreeNode source)
     : base(HqlSqlWalker.IN, "in", factory, itemExpression)
 {
     AddChild(new HqlInList(factory, source));
 }
		public IntermediateHqlTree(bool root)
		{
			_isRoot = root;
			TreeBuilder = new HqlTreeBuilder();
			_root = TreeBuilder.Query(TreeBuilder.SelectFrom(TreeBuilder.From()));
		}
		private void ExecuteAddOrderBy(HqlTreeNode orderBy)
		{
			if (orderBy == null)
				return;

			if (!_root.NodesPreOrder.Any(x => x == orderBy))
				_root.AddChild(orderBy);
		}
		public HqlIn In(HqlExpression itemExpression, HqlTreeNode source)
		{
			return new HqlIn(_factory, itemExpression, source);
		}
Beispiel #31
0
		public HqlDistinctHolder(IASTFactory factory, HqlTreeNode[] children) : base(int.MinValue, "distinct holder", factory, children)
		{
		}
Beispiel #32
0
		internal void AddChild(HqlTreeNode child)
		{
			if (child is HqlDistinctHolder)
			{
				AddChildren(child.Children);
			}
			else
			{
				_children.Add(child);
				_node.AddChild(child.AstNode);
			}
		}
 public HqlRange Range(HqlTreeNode ident, HqlAlias alias)
 {
     return(new HqlRange(_factory, ident, alias));
 }
 public HqlIn In(HqlExpression itemExpression, HqlTreeNode source)
 {
     return(new HqlIn(_factory, itemExpression, source));
 }
Beispiel #35
0
 public HqlInList(IASTFactory factory, HqlTreeNode source)
     : base(HqlSqlWalker.IN_LIST, "inlist", factory, source)
 {
 }
		public HqlInList(IASTFactory factory, HqlTreeNode source)
			: base(HqlSqlWalker.IN_LIST, "inlist", factory, source)
		{
		}
		private void DetectOuterExists()
		{
			if (_root is HqlExists)
			{
				_takeCount = TreeBuilder.Constant(1);
				_root = Root.Children.First();

				Expression<Func<IEnumerable<object>, bool>> x = l => l.Any();

				_listTransformers.Add(x);
			}
		}
		internal void AddChild(HqlTreeNode child)
		{
			if (child is HqlExpressionSubTreeHolder) 
			{
				AddChildren(child.Children);
			}
			else
			{
				_children.Add(child);
				_node.AddChild(child.AstNode);
			}
		}
		public void SetRoot(HqlTreeNode newRoot)
		{
			_root = newRoot;
		}
Beispiel #40
0
 public HqlJoin Join(HqlTreeNode expression, HqlAlias @alias)
 {
     return new HqlJoin(_factory, expression, @alias);
 }
        public ExpressionToHqlTranslationResults(HqlTreeNode statement, 
            IList<LambdaExpression> itemTransformers, 
            IList<LambdaExpression> listTransformers,
            IList<LambdaExpression> postExecuteTransformers,
            List<Action<IQuery, IDictionary<string, Tuple<object, IType>>>> additionalCriteria)
        {
            Statement = statement;

            PostExecuteTransformer = MergeLambdasAndCompile(postExecuteTransformers);

            var itemTransformer = MergeLambdasAndCompile(itemTransformers);
            var listTransformer = MergeLambdasAndCompile(listTransformers);

            if (itemTransformer != null || listTransformer != null)
            {
                 ResultTransformer = new ResultTransformer(itemTransformer, listTransformer);
            }

        	AdditionalCriteria = additionalCriteria;
        }