public static void AddEntityProps(this TableBuilder tb, EntityTable et, int entityOffset) { foreach (var p in et.PropertyLists.SelectMany(x => x.Value)) { tb.AddProperty(p.Id + entityOffset, p.Name, p.Value); } }
public static TableBuilder CreateTableCopy(this DocumentBuilder db, EntityTable table, List <int> remapping = null) { var name = table.Name.SimplifiedName(); var tb = db.CreateTableBuilder(name); foreach (var col in table.IndexColumns.Values.ToEnumerable()) { tb.AddIndexColumn(col.GetRelatedTableName(), col.GetFieldName(), col.GetTypedData().RemapData(remapping)); } foreach (var col in table.NumericColumns.Values.ToEnumerable()) { tb.AddColumn(col.Name, col.GetTypedData().RemapData(remapping)); } foreach (var col in table.StringColumns.Values.ToEnumerable()) { var strings = col.GetTypedData().Select(i => table.Document.StringTable.ElementAtOrDefault(i, null)); tb.AddColumn(col.Name, strings.ToArray().RemapData(remapping)); } // TODO: the remapping is non-trivial. Any table that is remapped, suggest that any references to the old table // also need to be remapped. I am not doing that right now, because this is a patch used only for Node tables. // Eventually I need to do something more sophisticated. I can't assume that all tables are remapped tables. // A simpler and more robust system would be to create tables from objects. There could be a big performance or // memory impact of that approach if I am not careful. It would be more robust right up to the use case of // merging data of data models, not yet anticipated. if (remapping != null && table.Properties.Any()) { throw new Exception("Currently can't remap tables with properties"); } foreach (var p in table.Properties) { tb.AddProperty(p.Id, p.Name, p.Value); } return(tb); }
public static IArray <INamedBuffer> GetExpandedColumns(this EntityTable et) => et.Columns.Concatenate(et.GetRelatedTables(et.Document).Select(t => t.Columns).Flatten());
public static IArray <EntityTable> GetRelatedTables(this EntityTable et, Document doc) => et.IndexColumns.Values.Select(v => GetRelatedTable(v, doc));
public static IArray <string> GetQualifiedColumnNames(this EntityTable table) => table.Columns.Select(c => c.GetTableQualifiedName(table));
public static IArray <string> GetShortColumnNames(this EntityTable table) => table.Columns.Select(c => c.GetShortName());
public static IArray <string> GetColumnNames(this EntityTable table) => table.Columns.Select(b => b.Name);
public static string GetTableQualifiedName(this INamedBuffer c, EntityTable table) => $"{table.Name}:{c.GetShortName()}";