public override Expression Evaluate(EvalStore store) { Table data = store.Get<Table>("$DATA"); int col = -1; if (data != null) { col = data.ColumnDefinitions.IndexOf(this.Name); } Element e = null; if (col >= 0) { List<int> group = store.Get<List<int>>("$GROUP"); if (group != null) { Element[] values = new Element[group.Count]; int i=0; foreach (int row in group) { values[i++]= data[row, col]; } e = new Element(values); } else { Element[] row = store.Get<Element[]>("$ROW"); e = row[col]; } } else { if (store.Exists(this.Name)) { e = store.Get<Element>(this.Name); } else { EvalContext ctx = store.Get<EvalContext>("$EVAL_CONTEXT"); if (ctx == null || ctx.Context != EvalContext.ContextType.SELECT) { if (!this.Name.Contains(" ")) { e = new Element(this.Name); } } } } if (e != null) { return new ConstExpr(e); } else { throw new Exception("No such column: " + this.Name); } }