예제 #1
0
        public IJoinState Join(string table, JoinType joinType)
        {
            Argument.NotWhiteSpace(table, "table");
            var joinTableSource = new SimpleTableSource(table);

            return(new JoinState(Query, joinTableSource, joinType));
        }
예제 #2
0
        private void AppendPartitioningConditions(QuerySpecification qs, SimpleTableSource ts)
        {
            if (!double.IsInfinity(PartitioningKeyFrom) || !double.IsInfinity(PartitioningKeyTo))
            {
                var cg = new SqlServerCodeGenerator();

                string format;
                if (double.IsInfinity(PartitioningKeyFrom) && double.IsInfinity(PartitioningKeyTo))
                {
                    format = "{1} <= {0} AND {0} < {2}";
                }
                else if (double.IsInfinity(PartitioningKeyFrom))
                {
                    format = "{0} < {2}";
                }
                else
                {
                    format = "{1} <= {0}";
                }

                string sql = String.Format(format,
                                           cg.GetResolvedColumnName(ts.PartitioningColumnReference),
                                           PartitioningKeyFrom.ToString(System.Globalization.CultureInfo.InvariantCulture),
                                           PartitioningKeyTo.ToString(System.Globalization.CultureInfo.InvariantCulture));

                var parser = new Jhu.Graywulf.SqlParser.SqlParser();
                var sc     = (SearchCondition)parser.Execute(new SearchCondition(), sql);

                var where = qs.FindDescendant <WhereClause>();
                if (where == null)
                {
                    where = WhereClause.Create(sc);
                    var ws = Whitespace.Create();

                    var wsn = qs.Stack.AddAfter(qs.Stack.Find(qs.FindDescendant <FromClause>()), ws);
                    qs.Stack.AddAfter(wsn, where);
                }
                else
                {
                    where.AppendCondition(sc, "AND");
                }
            }

            // --- remove partition clause
            ts.Stack.Remove(ts.FindDescendant <TablePartitionClause>());
        }
예제 #3
0
 public AliasedTableSource(SimpleTableSource source, string alias)
 {
     this.source = source;
     Alias       = alias;
 }