Esempio n. 1
0
        private DataColumn AddColumnToDataTable(Expression expression)
        {
            DataColumn dc = null;
            string newColName = expression.ToString();
            if (!_dt.Columns.Contains(newColName))
            {
                dc = _dt.Columns.Add(newColName, typeof(double));
                dc.ExtendedProperties[VBCommon.Globals.OPERATION] = true;

                foreach (string var in expression.Variables)
                {
                    DataColumn dc2 = _dt.Columns[var];
                    if (dc2.ExtendedProperties.ContainsKey(VBCommon.Globals.TRANSFORM))
                    {
                        dc.ExtendedProperties.Add(VBCommon.Globals.TRANSFORM, true);
                        break;
                    }
                }
            }
            return dc;
        }
Esempio n. 2
0
        /// <summary>
        /// Multiply the values of all the fields in the expression
        /// </summary>
        /// <param name="expression"></param>
        private void PRODUCT(Expression expression)
        {
            string newColName = expression.ToString();
            DataColumn dc = AddColumnToDataTable(expression);

            if (dc != null)
            {
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    double product = 1.0;
                    foreach (string var in expression.Variables)
                    {
                        product = product * Convert.ToDouble(_dt.Rows[i][var]);
                    }
                    _dt.Rows[i][newColName] = product;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sum the values of all the fields in the expression
        /// </summary>
        /// <param name="expression"></param>
        private void SUM(Expression expression)
        {
            string newColName = expression.ToString();
            DataColumn dc = AddColumnToDataTable(expression);

            if (dc != null)
            {
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    double sum = 0.0;
                    foreach (string var in expression.Variables)
                    {
                        sum += Convert.ToDouble(_dt.Rows[i][var]);
                    }
                    _dt.Rows[i][newColName] = sum;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Select the mininum values of all the fields in the expression
        /// </summary>
        /// <param name="expression"></param>
        private void MINIMUM(Expression expression)
        {
            string newColName = expression.ToString();
            DataColumn dc = AddColumnToDataTable(expression);

            if (dc != null)
            {
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    double min = double.PositiveInfinity;
                    foreach (string var in expression.Variables)
                    {
                        double current = Convert.ToDouble(_dt.Rows[i][var]);
                        if (current < min)
                            min = current;
                    }
                    _dt.Rows[i][newColName] = min;
                }
            }
        }