// ----------------------------------------------------------------------------- public void DeletePersonFromStaging(string cprNo) { if (dsUpdatedCPRs != null) { DataTable dt = dsUpdatedCPRs.Tables[0]; if (dt != null) { decimal pnr = GetCprNoAsDecimalFromString(cprNo); DataRow[] rowsForThisPerson = dt.Select(_UpdateDetectionVariables.PnrColumnName + "=" + pnr.ToString()); int idColIdx = dt.Columns.IndexOf(_UpdateDetectionVariables.IdColumnName); StringBuilder sb = new StringBuilder(); foreach (DataRow row in rowsForThisPerson) { if (ShouldIStop()) { return; } sb.Append(row[idColIdx].ToString() + ","); } string delStmt = sb.ToString(); // Remove trailing delimiter delStmt = delStmt.Substring(0, delStmt.Length - 1); // Build delete statement to delete this persons rows from batch () delStmt = "DELETE FROM [" + DatabaseName + "].[" + _UpdateDetectionVariables.SchemaName + "].[" + _UpdateDetectionVariables.StagingTableName + "] WHERE [" + _UpdateDetectionVariables.IdColumnName + "] IN (" + delStmt + ")"; CRUDContext dbCtx = new CRUDContext(_UpdateDetectionVariables.ConnectionStringName, delStmt); int rowCnt = dbCtx.ExecuteNonQuery(); } } }