public MultiTableUpdateScript GetLinkedDataScript(NameWithSchema basetable) { var res = new MultiTableUpdateScript(); if (ResultFields == null || !ResultFields.IsMultiTable()) { return(res); } var pks = new Dictionary <DmlfSource, List <DmlfColumnRef> >(); foreach (var row in Rows) { if (row.RowState != CdlRowState.Modified) { continue; } var changed = row.GetChangedColumnRefs(); if (changed.Length == 0) { continue; } var tbls = new List <DmlfSource>(); foreach (var ch in changed) { if (!tbls.Contains(ch.Source)) { tbls.Add(ch.Source); } } foreach (var src in tbls) { if (pks.ContainsKey(src)) { continue; } pks[src] = ResultFields.GetPrimaryKey(src); } foreach (var src in tbls) { var cols = new List <DmlfColumnRef>(); foreach (var ch in changed) { if (ch.Source != src) { continue; } cols.Add(ch); } var pk = pks[src]; res.Update(src == DmlfSource.BaseTable ? basetable : src.TableOrView, (from c in pk select c.ColumnName).ToArray(), row.Original.GetValuesByCols(pk.ToArray(), ResultFields), (from c in cols select c.ColumnName).ToArray(), row.GetValuesByCols(cols.ToArray())); } } return(res); }
public DataScript() { MainChanges = new SingleTableDataScript(); LinkedChanges = new MultiTableUpdateScript(); }
public void UpdateData(MultiTableUpdateScript script, LinkedDatabaseInfo linkedInfo) { }
public DataScript() { MainChanges = new SingleTableDataScript(); LinkedChanges = new MultiTableUpdateScript(); }
public void UpdateData(MultiTableUpdateScript script, LinkedDatabaseInfo linkedInfo) { if (script == null) return; string linkedInfoStr = linkedInfo != null ? linkedInfo.ToString() : ""; int updrows = 0, updflds = 0; foreach (var upd in script.Updates) { Put("^update %s%f ^set ", linkedInfoStr, upd.Table); for (int i = 0; i < upd.Columns.Length; i++) { if (i > 0) Put(", "); Put("%i=%v", upd.Columns[i], upd.Values[i]); } Where(upd.Table, upd.CondCols, upd.CondValues); Put(";&n"); updrows++; updflds += upd.Values.Length; } }