// Create a Table by converting a value // Each row has its own heading, which must match. public RelationValue TableC(HeadingValue hdgarg, params TypedValue[] valueargs) { Logger.Assert(valueargs.Length == 1, "TableC"); var heading = hdgarg.AsHeading(); var value = valueargs[0]; DataTable newtable = null; if (value.DataType is DataTypeTuple) { newtable = DataTableLocal.Create(heading, new DataRow[] { value.AsRow() }); } else if (value.DataType is DataTypeUser) { var user = value as UserValue; newtable = DataTableLocal.Create(heading, new DataRow[] { DataRow.Create(heading, user.Value) }); } else if (value.DataType is DataTypeRelation) { newtable = value.AsTable(); } Logger.Assert(newtable != null, "TableC"); Logger.WriteLine(3, "[Table={0}]", newtable); return(RelationValue.Create(newtable)); }
// Create a Table from row values and a heading // Each row has its own heading, which must match. public RelationValue TableV(HeadingValue hdgarg, params TypedValue[] rowargs) { var newtable = DataTable.Create(hdgarg.Value, rowargs.Select(r => r.AsRow())); Logger.WriteLine(3, "[Table={0}]", newtable); return(RelationValue.Create(newtable)); }
// Create a Table from a list of expressions that will yield rows // Each row has its own heading, which must match. public RelationValue Table(HeadingValue hdgarg, params CodeValue[] exprargs) { var exprs = exprargs.Select(e => e.AsEval).ToArray(); var newtable = DataTable.Create(hdgarg.Value, exprs); Logger.WriteLine(3, "[Table={0}]", newtable); return(RelationValue.Create(newtable)); }
static HeadingValue() { Default = new HeadingValue { Value = DataHeading.Empty }; }