Beispiel #1
0
        public override Table Operate(Database db)
        {
            Table.Column[] col = new Table.Column[columns.Length];
            for (int i = 0; i < columns.Length; i++)
            {
                col[i]      = new Table.Column();
                col[i].name = columns[i];
            }
            Table t = new Table(col);

            db.AddTable(name, t);
            return(t);
        }
Beispiel #2
0
        public override Table Value(Database db)
        {
            Table l = db.tables[left];
            Table r = right.Value(db);

            List <Table.Column> cols = new List <Table.Column>();

            for (int i = 0; i < l.columns.Length; i++)
            {
                Table.Column c = new Table.Column();
                c.name = "left." + l.columns[i].name;
                cols.Add(c);
            }
            for (int i = 0; i < r.columns.Length; i++)
            {
                Table.Column c = new Table.Column();
                c.name = "right." + r.columns[i].name;
                cols.Add(c);
            }

            Table j = new Table(cols.ToArray());

            foreach (Table.Row row in l.rows)
            {
                foreach (Table.Row row2 in r.rows)
                {
                    Table.Row jr = new Table.Row();
                    foreach (KeyValuePair <string, string> pair in row.values)
                    {
                        jr.values["left." + pair.Key] = pair.Value;
                    }
                    foreach (KeyValuePair <string, string> pair in row2.values)
                    {
                        jr.values["right." + pair.Key] = pair.Value;
                    }
                    j.rows.Add(jr);
                }
            }
            return(j);
        }
Beispiel #3
0
        public override Table Operate(Database db)
        {
            Table src = source.Value(db);

            Table.Column[] col;
            if (!all)
            {
                col = new Table.Column[fields.Length];
                for (int i = 0; i < fields.Length; i++)
                {
                    col[i]      = new Table.Column();
                    col[i].name = fields[i];
                }
            }
            else
            {
                col = new Table.Column[src.columns.Length];
                for (int i = 0; i < src.columns.Length; i++)
                {
                    col[i]      = new Table.Column();
                    col[i].name = src.columns[i].name;
                }
            }
            Table result = new Table(col);

            foreach (Table.Row row in src.rows)
            {
                bool eval = this.expr.Evaluate(row) == "TRUE";
                if (eval)
                {
                    result.rows.Add(row);
                }
            }

            return(result);
        }