/// <summary> /// Clone then import rows /// </summary> public DmTable Copy() { try { DmTable destTable = this.Clone(); foreach (DmRow row in Rows) { destTable.ImportRow(row); } return(destTable); } finally { } }
public DmSet GetChanges(DmRowState rowStates) { DmSet dsNew = null; if (0 != (rowStates & ~(DmRowState.Added | DmRowState.Deleted | DmRowState.Modified | DmRowState.Unchanged))) { throw new Exception($"InvalidRowState {rowStates}"); } // Initialize all the individual table bitmaps. TableChanges[] bitMatrix = new TableChanges[Tables.Count]; for (int i = 0; i < bitMatrix.Length; ++i) { bitMatrix[i] = new TableChanges(Tables[i].Rows.Count); } // find all the modified rows and their parents MarkModifiedRows(bitMatrix, rowStates); // copy the changes to a cloned table for (int i = 0; i < bitMatrix.Length; ++i) { Debug.Assert(0 <= bitMatrix[i].HasChanges, "negative change count"); if (0 < bitMatrix[i].HasChanges) { if (dsNew == null) { dsNew = this.Clone(); } DmTable table = this.Tables[i]; DmTable destTable = dsNew.Tables.First(t => t.TableName == table.TableName); for (int j = 0; 0 < bitMatrix[i].HasChanges; ++j) { // Loop through the rows. if (bitMatrix[i][j]) { destTable.ImportRow(table.Rows[j]); bitMatrix[i].HasChanges--; } } } } return(dsNew); }
/// <summary> /// Get Changes from the DmTable, with a DmRowState value /// </summary> public DmTable GetChanges(DmRowState rowStates) { DmTable dtChanges = this.Clone(); DmRow row = null; for (int i = 0; i < Rows.Count; i++) { row = Rows[i]; if ((row.RowState & rowStates) == row.RowState) { dtChanges.ImportRow(row); } } if (dtChanges.Rows.Count == 0) { return(null); } return(dtChanges); }
/// <summary> /// Get Changes from the DmTable /// </summary> public DmTable GetChanges() { DmTable dtChanges = this.Clone(); DmRow row = null; for (int i = 0; i < Rows.Count; i++) { row = Rows[i]; if (row.oldRecord != row.newRecord) { dtChanges.ImportRow(row); } } if (dtChanges.Rows.Count == 0) { return(null); } return(dtChanges); }