예제 #1
0
 public ExpressionColumnCollection(ExpressionTable table)
     : base(table)
 {
     this.table = table;
 }
예제 #2
0
        private ITable ExpressionTableFilter(ITable table, FilterExpression op)
        {
            // The filter operation which is a function that describes the output
            // columns
            Expression filterExp = op.Filter;
            if (filterExp.Type != ExpressionType.Function)
                throw new ApplicationException("Expected a function.");

            FunctionExpression functionExp = (FunctionExpression)filterExp;

            // Function name and parameter count,
            string funName = functionExp.Name;
            if (!funName.Equals("table_out"))
                throw new ArgumentException();

            int paramCount = functionExp.Parameters.Count;

            // Create the expression table data source
            ExpressionTable expressionTable = new ExpressionTable(table, this);

            // The number of parameters,
            for (int i = 0; i < paramCount; ++i) {
                Expression outExp = (Expression) functionExp.Parameters[i];
                // This will always be an aliasvarname with an operation child which is
                // the expression we perform for the column.
                if (!(outExp is AliasVariableNameExpression))
                    throw new ApplicationException("Expected ALIASVARNAME.");

                // The label,
                Variable v = ((AliasVariableNameExpression)outExp).Alias;
                string label = v.Name;
                // The actual function
                Expression funExp = ((AliasVariableNameExpression) outExp).Child;
                // Work out the type,
                SqlType expType = GetExpressionType(table, funExp);
                // Add the column
                expressionTable.AddColumn(label, expType, funExp);
            }

            // Return the operation table
            return expressionTable;
        }