Ejemplo n.º 1
0
        /// <summary>
        /// コンストラクタ、親ノードと結合種類、テーブル、結合式を指定して初期化する
        /// </summary>
        /// <param name="parent">親ノード</param>
        /// <param name="joinType">結合種類</param>
        /// <param name="table">結合するテーブル</param>
        /// <param name="on">結合式</param>
        public Join(IQueryNode parent, JoinType joinType, ITable <TColumns> table, Expression <Func <TColumns, bool> > on)
        {
            var select = table as ISelect <TColumns>;

            if (select is null)
            {
                table = table.AliasedClone();
            }
            else
            {
                QueryNodeHelper.SwitchParent(select, this);
            }

            this.Parent   = parent;
            this.JoinType = joinType;
            this.Table    = table;
            this.Columns  = table.Columns;

            this.Owner.RegisterTable(table);

            this.On = new ElementCode(
                ParameterReplacer.Replace(
                    on.Body,
                    new Dictionary <Expression, object> {
                { on.Parameters[0], table.Columns }
            }
                    ),
                this.Owner.AllColumns
                );
        }
Ejemplo n.º 2
0
        public EqualQueryNode(Expression path, object value)
        {
            var convertedValue = QueryNodeHelper.ConvertValue(path, value);

            _expression =
                Expression.Equal(path, Expression.Constant(convertedValue));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 指定ノードを子とする、既存の親は<see cref="RemoveChild(IQueryNode)"/>で切り離す必要がある
 /// </summary>
 /// <param name="child">子ノード</param>
 public void AddChild(IQueryNode child)
 {
     if (!this.Children.Contains(child))
     {
         QueryNodeHelper.SwitchParent(child, this);
         this.Children.Add(child);
     }
 }
Ejemplo n.º 4
0
        public BinaryNode(Expression left, JProperty property)
        {
            var convertedValue = QueryNodeHelper.ConvertValue(left, property.Value);

            var expressionType = Arguments[property.Name];

            _expression =
                Expression.MakeBinary(expressionType, left, Expression.Constant(convertedValue));
        }
Ejemplo n.º 5
0
 public From <TColumns> Limit(ILimit limit)
 {
     if (this.LimitNode != null)
     {
         throw new ApplicationException();
     }
     QueryNodeHelper.SwitchParent(limit, this);
     this.LimitNode = limit;
     return(this);
 }
Ejemplo n.º 6
0
 public From <TColumns> OrderBy(IOrderBy orderBy)
 {
     if (this.OrderByNode != null)
     {
         throw new ApplicationException();
     }
     QueryNodeHelper.SwitchParent(orderBy, this);
     this.OrderByNode = orderBy;
     return(this);
 }
Ejemplo n.º 7
0
 public From <TColumns> GroupBy(IGroupBy groupBy)
 {
     if (this.GroupByNode != null)
     {
         throw new ApplicationException();
     }
     QueryNodeHelper.SwitchParent(groupBy, this);
     this.GroupByNode = groupBy;
     return(this);
 }
Ejemplo n.º 8
0
 public From <TColumns> Where(IWhere where)
 {
     if (this.WhereNode != null)
     {
         throw new ApplicationException();
     }
     QueryNodeHelper.SwitchParent(where, this);
     this.WhereNode = where;
     return(this);
 }
Ejemplo n.º 9
0
 public From <TColumns> Join(IJoin join)
 {
     if (this.JoinNodes == null)
     {
         this.JoinNodes = new List <IJoin>();
     }
     QueryNodeHelper.SwitchParent(join, this);
     this.JoinNodes.Add(join);
     return(this);
 }
Ejemplo n.º 10
0
 public SelectFrom <TSelectedColumns> From(IFrom from)
 {
     if (this.FromNode != null)
     {
         throw new ApplicationException();
     }
     QueryNodeHelper.SwitchParent(from, this);
     this.FromNode = from;
     return(this);
 }
Ejemplo n.º 11
0
 public ValueSetter Where(IWhere where)
 {
     if (this.WhereNode != null)
     {
         throw new ApplicationException();
     }
     QueryNodeHelper.SwitchParent(where, this);
     this.WhereNode = where;
     return(this);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 指定ノードを子とする、既存の親は<see cref="RemoveChild(IQueryNode)"/>で切り離す必要がある
        /// </summary>
        /// <param name="child">子ノード</param>
        public void AddChild(IQueryNode child)
        {
            var select = child as ISelect;

            if (select != null)
            {
                if (this.ValueNode != null)
                {
                    throw new ApplicationException();
                }
                QueryNodeHelper.SwitchParent(select, this);
                this.ValueNode = select;
            }
            else
            {
                throw new ApplicationException();
            }
        }
Ejemplo n.º 13
0
        public From(IQueryNode parent, ITable <TColumns> table)
        {
            var select = table as ISelect <TColumns>;

            if (select is null)
            {
                table = table.AliasedClone();
            }
            else
            {
                QueryNodeHelper.SwitchParent(select, this);
            }

            this.Parent  = parent;
            this.Table   = table;
            this.Columns = table.Columns;

            this.Owner.RegisterTable(table);
        }