Beispiel #1
0
        private void GenerateStatementSelect(Select.Select statement, TextWriter writer, CodeGeneratorOptions options)
        {
            writer.Write("SELECT");
            using (new IndentHelper(writer))
            {

                if (statement.SelectTop != null)
                {
                    writer.Write(" ");
                    GenerateCodeFromExpression(statement.SelectTop, writer, options);
                }

                if (statement.SelectList != null && statement.SelectList.Count > 0)
                {
                    int i = 0;
                    foreach (var selectItem in statement.SelectList)
                    {
                        if (0 < i++) { writer.Write(","); }
                        GenerateCodeFromCodeObject(selectItem, writer, options);
                    }
                }
                if (statement.From != null)
                {
                    writer.WriteLine();
                    GenerateCodeFromStatement(statement.From, writer, options);
                }
                if (statement.Where != null)
                {
                    writer.WriteLine();
                    GenerateCodeFromStatement(statement.Where, writer, options);
                }
                if (statement.GroupBy != null)
                {
                    writer.WriteLine();
                    GenerateCodeFromStatement(statement.GroupBy, writer, options);
                }
                if (statement.Having != null)
                {
                    writer.WriteLine();
                    GenerateCodeFromStatement(statement.Having, writer, options);
                }
                if (statement.OrderBy != null)
                {
                    writer.WriteLine();
                    GenerateCodeFromStatement(statement.OrderBy, writer, options);
                }
                writer.Write(";");
            }
        }
Beispiel #2
0
 public ScalarSelect(Top top, Expression selectItem, From.From from, Where.Where where, GroupBy.GroupBy groupBy, OrderBy.OrderBy orderBy)
     : base(null)
 {
     _select = new Select(top, selectItem, from, where, groupBy, orderBy);
 }
Beispiel #3
0
 public void SelectTest1()
 {
     var table = new Table("test");
     var orderByExpression = table["foo"].Asc();
     OrderBy.OrderBy target = new OrderBy.OrderBy(orderByExpression);
     Column[] selectedItems = new Column[] { table["foo"] };
     From.From from = new From.From(table);
     Select.Select expected = new Select.Select(selectedItems, from, target);
     Select.Select actual;
     actual = target.Select(selectedItems);
     Assert.AreEqual(target, actual.OrderBy);
 }
Beispiel #4
0
 public ScalarSelect(Top top, Expression selectItem, From.From from, Where.Where where)
     : base(null)
 {
     _select = new Select(null, selectItem, from, where);
 }
Beispiel #5
0
 public void SelectTest()
 {
     var table = new Table("test");
     var orderByExpression = table["foo"].Asc();
     OrderBy.OrderBy target = new OrderBy.OrderBy(orderByExpression);
     Expression selectItem = table["foo"];
     From.From from = new From.From(table);
     Select.Select expected = new Select.Select(selectItem, from, target); // TODO: Initialize to an appropriate value
     Select.Select actual = target.Select(selectItem);
     Assert.AreEqual(target, actual.OrderBy);
 }