Eval() abstract private method

abstract private Eval ( ) : object
return object
        internal object Evaluate(DataRow row, DataRowVersion version)
        {
            object result;

            if (!_bound)
            {
                Bind(_table);
            }
            if (_expr != null)
            {
                result = _expr.Eval(row, version);
                // if the type is a SqlType (StorageType.Uri < _storageType), convert DBNull values.
                if (result != DBNull.Value || StorageType.Uri < _storageType)
                {
                    // we need to convert the return value to the column.Type;
                    try
                    {
                        if (StorageType.Object != _storageType)
                        {
                            result = SqlConvert.ChangeType2(result, _storageType, _dataType, _table.FormatProvider);
                        }
                    }
                    catch (Exception e) when(ADP.IsCatchableExceptionType(e))
                    {
                        ExceptionBuilder.TraceExceptionForCapture(e);
                        throw ExprException.DatavalueConvertion(result, _dataType, e);
                    }
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <include file='doc\DataExpression.uex' path='docs/doc[@for="DataExpression.Evaluate1"]/*' />
        public virtual object Evaluate(DataRow row, DataRowVersion version)
        {
            object result;

            if (!bound)
            {
                this.Bind(this.table);
            }
            if (expr != null)
            {
                result = expr.Eval(row, version);
                if (result != DBNull.Value)
                {
                    // we need to convert the return value to the column.Type;
                    try {
                        if (typeof(object) != this.type)
                        {
                            result = Convert.ChangeType(result, this.type);
                        }
                    }
                    catch (Exception) {
                        // CONSIDER: keep the original exception, add it to the error text
                        // CONSIDER: Get the column name in the error to know which computation is failing.
                        throw ExprException.DatavalueConvertion(result, type);
                    }
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }
Ejemplo n.º 3
0
 private static object Eval(ExpressionNode expr, DataRow row, DataRowVersion version, int[] recordNos)
 {
     if (recordNos == null)
     {
         return(expr.Eval(row, version));
     }
     else
     {
         return(expr.Eval(recordNos));
     }
 }
Ejemplo n.º 4
0
        private bool AcceptRecord(int record)
        {
            DataRow row = _table._recordManager[record];

            if (row == null)
            {
                return(true);
            }

            DataRowVersion version = DataRowVersion.Default;

            if (row._oldRecord == record)
            {
                version = DataRowVersion.Original;
            }
            else if (row._newRecord == record)
            {
                version = DataRowVersion.Current;
            }
            else if (row._tempRecord == record)
            {
                version = DataRowVersion.Proposed;
            }

            object val = _linearExpression.Eval(row, version);
            bool   result;

            try
            {
                result = DataExpression.ToBoolean(val);
            }
            catch (Exception e) when(ADP.IsCatchableExceptionType(e))
            {
                throw ExprException.FilterConvertion(_rowFilter.Expression);
            }
            return(result);
        }
Ejemplo n.º 5
0
 internal override object Eval(DataRow row, DataRowVersion version)
 {
     return(EvalUnaryOp(_op, _right.Eval(row, version)));
 }
Ejemplo n.º 6
0
 private static object Eval(ExpressionNode expr, DataRow row, DataRowVersion version, int[] recordNos)
 {
     if (recordNos == null)
     {
         return expr.Eval(row, version);
     }
     else
     {
         return expr.Eval(recordNos);
     }
 }