Exemplo n.º 1
0
        public static IEnumerable <long> SelectRows(this ITable table, int column, Operator op, DataObject cell)
        {
            // If the cell is of an incompatible type, return no results,
            DataType colType = table.TableInfo[column].DataType;

            if (!cell.DataType.IsComparable(colType))
            {
                // Types not comparable, so return 0
                return(new List <long>(0));
            }

            // Get the selectable scheme for this column
            SelectableScheme ss = table.GetScheme(column);

            // If the operator is a standard operator, use the interned SelectableScheme
            // methods.
            if (op.IsEquivalent(Operator.Equal))
            {
                return(ss.SelectEqual(cell));
            }
            if (op.IsEquivalent(Operator.NotEqual))
            {
                return(ss.SelectNotEqual(cell));
            }
            if (op.IsEquivalent(Operator.Greater))
            {
                return(ss.SelectGreater(cell));
            }
            if (op.IsEquivalent(Operator.Smaller))
            {
                return(ss.SelectLess(cell));
            }
            if (op.IsEquivalent(Operator.GreaterOrEqual))
            {
                return(ss.SelectGreaterOrEqual(cell));
            }
            if (op.IsEquivalent(Operator.SmallerOrEqual))
            {
                return(ss.SelectLessOrEqual(cell));
            }

            // If it's not a standard operator (such as IS, NOT IS, etc) we generate the
            // range set especially.
            SelectableRangeSet rangeSet = new SelectableRangeSet();

            rangeSet.Intersect(op, cell);
            return(ss.SelectRange(rangeSet.ToArray()));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates a range with the given expression.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="range"></param>
        /// <param name="field"></param>
        /// <param name="e"></param>
        private static void UpdateRange(IQueryContext context, SelectableRangeSet range, DataColumnInfo field, Expression e)
        {
            var      binary = (BinaryExpression)e;
            Operator op     = binary.Operator;

            Expression[] exps = { binary.Left, binary.Right };

            // Evaluate to an object
            DataObject cell = exps[1].Evaluate(context);

            // If the evaluated object is not of a comparable type, then it becomes
            // null.
            DataType fieldType = field.DataType;

            if (!cell.DataType.IsComparable(fieldType))
            {
                cell = new DataObject(fieldType, null);
            }

            // Intersect this in the range set
            range.Intersect(op, cell);
        }