Ejemplo n.º 1
0
        protected ResultSet.ResultSet Apply(ResultSet.ResultSet rs, Func <bool, bool> onApply)
        {
            var filteredRs = new ResultSet.ResultSet();
            var table      = rs.Table.Clone();

            filteredRs.Load(table);
            filteredRs.Table.Clear();

            foreach (DataRow row in rs.Rows)
            {
                if (onApply(RowApply(row)))
                {
                    if (filteredRs.Rows.Count == 0 && filteredRs.Columns.Count != row.Table.Columns.Count)
                    {
                        foreach (DataColumn column in row.Table.Columns)
                        {
                            if (!filteredRs.Columns.Cast <DataColumn>().Any(x => x.ColumnName == column.ColumnName))
                            {
                                filteredRs.Columns.Add(column.ColumnName, typeof(object));
                            }
                        }
                    }
                    filteredRs.Table.ImportRow(row);
                }
            }

            filteredRs.Table.AcceptChanges();
            return(filteredRs);
        }
Ejemplo n.º 2
0
        public ResultSet.ResultSet AntiApply(ResultSet.ResultSet rs)
        {
            if (rs == null)
            {
                throw new ArgumentNullException();
            }

            var filteredRs = new ResultSet.ResultSet();
            var table      = rs.Table.Clone();

            filteredRs.Load(table);
            return(filteredRs);
        }
Ejemplo n.º 3
0
        public ResultSet.ResultSet Apply(ResultSet.ResultSet rs)
        {
            var newRs  = rs.Clone();
            var groups = groupBy.Execute(rs);

            foreach (var group in groups)
            {
                var groupRs = new ResultSet.ResultSet();
                groupRs.Load(group.Value);
                var filtered = filter.Apply(groupRs);
                newRs.AddRange(filtered.Rows.Cast <DataRow>());
            }
            return(newRs);
        }
Ejemplo n.º 4
0
        protected ResultSet.ResultSet Apply(ResultSet.ResultSet rs, Func <bool, bool> onApply)
        {
            var filteredRs = new ResultSet.ResultSet();
            var table      = rs.Table.Clone();

            filteredRs.Load(table);

            foreach (DataRow row in rs.Rows)
            {
                if (onApply(RowApply(row)))
                {
                    filteredRs.Table.ImportRow(row);
                }
            }

            filteredRs.Table.AcceptChanges();
            return(filteredRs);
        }
Ejemplo n.º 5
0
        protected ResultSet.ResultSet Apply(ResultSet.ResultSet rs, Func <bool, bool> onApply)
        {
            var filteredRs = new ResultSet.ResultSet();
            var table      = rs.Table.Clone();

            filteredRs.Load(table);

            foreach (DataRow row in rs.Rows)
            {
                var value = GetValueFromRow(row, operand);
                if (onApply(executeFunction(value)))
                {
                    filteredRs.Table.ImportRow(row);
                }
            }

            filteredRs.Table.AcceptChanges();
            return(filteredRs);
        }
Ejemplo n.º 6
0
        protected ResultSet.ResultSet Apply(ResultSet.ResultSet rs, Func <bool, bool> onApply)
        {
            var filteredRs = new ResultSet.ResultSet();
            var table      = rs.Table.Clone();

            filteredRs.Load(table);


            var factory   = new PredicateFactory();
            var predicate = factory.Get(predicateInfo);

            foreach (DataRow row in rs.Rows)
            {
                var dico = new Dictionary <string, object>();
                foreach (var variable in variables)
                {
                    dico.Add(variable.Name, row[variable.Column]);
                }

                foreach (var expression in expressions)
                {
                    var exp = new NCalc.Expression(expression.Value);
                    exp.Parameters = dico;
                    var result = exp.Evaluate();
                    dico.Add(expression.Name, result);
                }

                var value = dico[predicateInfo.Name];
                if (onApply(predicate.Compare(value, predicateInfo.Reference)))
                {
                    filteredRs.Table.ImportRow(row);
                }
            }

            filteredRs.Table.AcceptChanges();
            return(filteredRs);
        }