public override ITable Evaluate(IQueryContext context) { var viewName = TableInfo.TableName; // We have to execute the plan to get the DataTableInfo that represents the // result of the view execution. var t = QueryPlan.Evaluate(context); var tableInfo = t.TableInfo.Alias(viewName); var viewInfo = new ViewInfo(tableInfo, QueryExpression, QueryPlan); context.DefineView(viewInfo); // The initial grants for a view is to give the user who created it // full access. context.GrantToUserOnTable(viewName, Privileges.TableAll); return FunctionTable.ResultTable(context, 0); }