Exemple #1
0
        public static ITable ExecuteCreateView(this IQuery query, string viewName, IEnumerable <string> columnNames,
                                               SqlQueryExpression queryExpression)
        {
            var statement = new CreateViewStatement(viewName, columnNames, queryExpression);

            return(statement.Execute(query));
        }
 protected override void BuildStatement(SqlCodeObjectBuilder builder)
 {
     var queryExpression = (SqlQueryExpression)ExpressionBuilder.Build(QueryExpression);
     var statement = new CreateViewStatement(ViewName.Name, ColumnNames, queryExpression);
     statement.ReplaceIfExists = ReplaceIfExists;
     builder.AddObject(statement);
 }
Exemple #3
0
 protected virtual SqlStatement VisitCreateView(CreateViewStatement statement)
 {
     return(new CreateViewStatement(statement.ViewName, statement.ColumnNames, statement.QueryExpression)
     {
         ReplaceIfExists = statement.ReplaceIfExists
     });
 }
        public static void WithNoColumns()
        {
            var query = (SqlQueryExpression) SqlExpression.Parse("SELECT * FROM test1 WHERE a > 2");
            var statement = new CreateViewStatement(ObjectName.Parse("APP.view1"), query);

            var sql = statement.ToString();
            var expected = new SqlStringBuilder();
            expected.AppendLine("CREATE VIEW APP.view1 IS");
            expected.Append("  SELECT * FROM test1 WHERE a > 2");
            Assert.AreEqual(expected.ToString(), sql);
        }
        public static void WithColumns()
        {
            var query     = (SqlQueryExpression)SqlExpression.Parse("SELECT id AS a, name AS b FROM test1 WHERE a > 2");
            var statement = new CreateViewStatement(ObjectName.Parse("APP.view1"), new [] { "a", "b" }, query);

            var sql      = statement.ToString();
            var expected = new SqlStringBuilder();

            expected.AppendLine("CREATE VIEW APP.view1(a, b) IS");
            expected.Append("  SELECT id AS a, name AS b FROM test1 WHERE a > 2");
            Assert.AreEqual(expected.ToString(), sql);
        }
Exemple #6
0
 protected virtual SqlStatement VisitCreateView(CreateViewStatement statement)
 {
     return new CreateViewStatement(statement.ViewName, statement.ColumnNames, statement.QueryExpression) {
         ReplaceIfExists = statement.ReplaceIfExists
     };
 }
Exemple #7
0
 public override void VisitCreateView(CreateViewNode node)
 {
     var queryExpression = (SqlQueryExpression)Expression(node.QueryExpression);
     var statement = new CreateViewStatement(node.ViewName.Name, node.ColumnNames, queryExpression);
     statements.Add(statement);
 }
        public static ITable ExecuteCreateView(this IQueryContext context, string viewName, IEnumerable<string> columnNames,
			SqlQueryExpression queryExpression)
        {
            var statement = new CreateViewStatement(viewName, columnNames, queryExpression);
            return statement.Execute(context);
        }
 private void BuildCreateView(CreateViewNode node)
 {
     var queryExpression = (SqlQueryExpression)Expression(node.QueryExpression);
     var statement = new CreateViewStatement(node.ViewName.Name, node.ColumnNames, queryExpression);
     statements.Add(statement);
 }