internal static InsertFragment InsertTemptable(this ContentBase data, TemporaryTableFragment temptable, CommitKeyUnit unit, DbName name = null) { var members = unit.Keys.Concat(unit.Members).Select(a => a.Metadata); var context = data.GenerateContext; var table = new TableFragment(context, unit.Table, name); var select = new SelectFragment(context, temptable); var current = new InsertFragment(context, table, select); foreach (var member in members) { select.CreateMember(null, temptable.GetMember(member)); current.CreateMember(null, member); } return(current); }
public static InsertFragment Insert(this GenerateContext context, ISourceFragment source, TableMetadata target , IEnumerable <ColumnMetadata> members) { DbName name = null; if (context.Data is ContentBase data) { name = data.TargetName; } var table = new TableFragment(context, target, name); var select = new SelectFragment(context, source); var current = new InsertFragment(context, table, select); foreach (var member in members) { select.CreateMember(null, source.GetMember(member)); current.CreateMember(null, member); } return(current); }