예제 #1
0
        public FunctionTable(ITable table, SqlExpression[] functionList, string[] columnNames, IRequest queryContext)
            : base(queryContext.Context)
        {
            // Make sure we are synchronized over the class.
            lock (typeof(FunctionTable)) {
                uniqueId = uniqueKeySeq;
                ++uniqueKeySeq;
            }

            uniqueId = (uniqueId & 0x0FFFFFFF) | 0x010000000;

            context = queryContext;

            ReferenceTable = table;
            varResolver = table.GetVariableResolver();
            varResolver = varResolver.ForRow(0);

            // Create a DataTableInfo object for this function table.
            funTableInfo = new TableInfo(FunctionTableName);

            expList = new SqlExpression[functionList.Length];
            expInfo = new byte[functionList.Length];

            // Create a new DataColumnInfo for each expression, and work out if the
            // expression is simple or not.
            for (int i = 0; i < functionList.Length; ++i) {
                var expr = functionList[i];
                // Examine the expression and determine if it is simple or not
                if (expr.IsConstant() && !expr.HasAggregate(context)) {
                    // If expression is a constant, solve it
                    var result = expr.Evaluate(context, null);
                    if (result.ExpressionType != SqlExpressionType.Constant)
                        throw new InvalidOperationException();

                    expr = result;
                    expList[i] = expr;
                    expInfo[i] = 1;
                } else {
                    // Otherwise must be dynamic
                    expList[i] = expr;
                    expInfo[i] = 0;
                }

                // Make the column info
                funTableInfo.AddColumn(columnNames[i], expr.ReturnType(context, varResolver));
            }

            // Make sure the table info isn't changed from this point on.
            funTableInfo = funTableInfo.AsReadOnly();

            // routine tables are the size of the referring table.
            rowCount = table.RowCount;

            // Set schemes to 'blind search'.
            SetupIndexes(DefaultIndexTypes.BlindSearch);
        }
예제 #2
0
        public FunctionTable(ITable table, SqlExpression[] functionList, string[] columnNames, IRequest queryContext)
            : base(queryContext.Context)
        {
            // Make sure we are synchronized over the class.
            lock (typeof(FunctionTable)) {
                uniqueId = uniqueKeySeq;
                ++uniqueKeySeq;
            }

            uniqueId = (uniqueId & 0x0FFFFFFF) | 0x010000000;

            context = queryContext;

            ReferenceTable = table;
            varResolver    = table.GetVariableResolver();
            varResolver    = varResolver.ForRow(0);

            // Create a DataTableInfo object for this function table.
            funTableInfo = new TableInfo(FunctionTableName);

            expList = new SqlExpression[functionList.Length];
            expInfo = new byte[functionList.Length];

            // Create a new DataColumnInfo for each expression, and work out if the
            // expression is simple or not.
            for (int i = 0; i < functionList.Length; ++i)
            {
                var expr = functionList[i];
                // Examine the expression and determine if it is simple or not
                if (expr.IsConstant() && !expr.HasAggregate(context))
                {
                    // If expression is a constant, solve it
                    var result = expr.Evaluate(context, null);
                    if (result.ExpressionType != SqlExpressionType.Constant)
                    {
                        throw new InvalidOperationException();
                    }

                    expr       = result;
                    expList[i] = expr;
                    expInfo[i] = 1;
                }
                else
                {
                    // Otherwise must be dynamic
                    expList[i] = expr;
                    expInfo[i] = 0;
                }

                // Make the column info
                funTableInfo.AddColumn(columnNames[i], expr.ReturnType(context, varResolver));
            }

            // Make sure the table info isn't changed from this point on.
            funTableInfo = funTableInfo.AsReadOnly();

            // routine tables are the size of the referring table.
            rowCount = table.RowCount;

            // Set schemes to 'blind search'.
            SetupIndexes(DefaultIndexTypes.BlindSearch);
        }