Пример #1
0
        // ---------- Convenience statics ----------

        ///<summary>
        /// Returns a FunctionTable that has a single Expression evaluated in it.
        ///</summary>
        ///<param name="context"></param>
        ///<param name="expression"></param>
        /// <remarks>
        /// The column name is 'result'.
        /// </remarks>
        ///<returns></returns>
        public static Table ResultTable(IQueryContext context, Expression expression)
        {
            Expression[]      exp            = new Expression[] { expression };
            string[]          names          = new String[] { "result" };
            Table             function_table = new FunctionTable(exp, names, context);
            SubsetColumnTable result         = new SubsetColumnTable(function_table);

            int[]        map  = new int[] { 0 };
            ObjectName[] vars = new[] { new ObjectName("result") };
            result.SetColumnMap(map, vars);

            return(result);
        }
Пример #2
0
        public override ITable Evaluate(IQueryContext context)
        {
            Table t = (Table) Child.Evaluate(context);

            int sz = originalColumns.Length;
            int[] colMap = new int[sz];

            for (int i = 0; i < sz; ++i) {
                int mapped = t.FindFieldName(originalColumns[i]);
                if (mapped == -1)
                    throw new InvalidOperationException(String.Format("Column {0} was not found in table {1} when subsetting.", originalColumns[i], t.TableInfo.Name));

                colMap[i] = mapped;
            }

            var subsetTable = new SubsetColumnTable((Table)t);
            subsetTable.SetColumnMap(colMap, newColumnNames);
            return subsetTable;
        }
Пример #3
0
        // ---------- Convenience statics ----------
        ///<summary>
        /// Returns a FunctionTable that has a single Expression evaluated in it.
        ///</summary>
        ///<param name="context"></param>
        ///<param name="expression"></param>
        /// <remarks>
        /// The column name is 'result'.
        /// </remarks>
        ///<returns></returns>
        public static Table ResultTable(IQueryContext context, Expression expression)
        {
            Expression[] exp = new Expression[] { expression };
            string[] names = new String[] {"result"};
            Table function_table = new FunctionTable(exp, names, context);
            SubsetColumnTable result = new SubsetColumnTable(function_table);

            int[] map = new int[] {0};
            ObjectName[] vars = new[] {new ObjectName("result")};
            result.SetColumnMap(map, vars);

            return result;
        }