/// <summary> /// This method overloads the base class method to support DAS specific properties. /// </summary> /// <param name="table">Table to be merged.</param> /// <param name="preserveChanges"><c>True</c> means all changes are preserved.</param> /// <param name="missingSchemaAction"><seealso cref="System.Data.MissingSchemaAction"></seealso></param> public void Merge(DASDataTable table, bool preserveChanges, MissingSchemaAction missingSchemaAction) { base.Merge(table, preserveChanges, missingSchemaAction); foreach (DASDataRow row in table.Rows) { var _with1 = Rows.ItemByDBKey(row.DBKey); _with1.SQL = row.SQL; } }
/// <summary> /// This function checks whether the row does exists in the database. /// </summary> /// <returns><c>True</c>, if row exists.</returns> public bool ExistsInDB() { bool ReturnValue = false; var stringBuilder = new StringBuilder(); var TableDAS = Table.DAS; DataRowVersion rowVersion; var dataTable = new DASDataTable(TableDAS) { DBTableName = Table.DBTableName }; switch (RowState) { case DataRowState.Added: rowVersion = DataRowVersion.Current; break; case DataRowState.Detached: rowVersion = DataRowVersion.Default; break; default: rowVersion = DataRowVersion.Original; break; } long i = 1; foreach (DASDataColumn column in Table.PrimaryKey) { switch (column.DASDataType) { case DASDataColumn.DASDataTypes.DASDATE: TableDAS.AddParameter(string.Format("@P{0}", i), this[column, rowVersion], DAS.ParameterModes.PARM_IN, DAS.ServerTypes.ST_DATE); break; case DASDataColumn.DASDataTypes.DASDOUBLE: case DASDataColumn.DASDataTypes.DASLONG: TableDAS.AddParameter(string.Format("@P{0}", i), this[column, rowVersion], DAS.ParameterModes.PARM_IN, DAS.ServerTypes.ST_NUMBER); break; case DASDataColumn.DASDataTypes.DASSTRING: TableDAS.AddParameter(string.Format("@P{0}", i), this[column, rowVersion], DAS.ParameterModes.PARM_IN, DAS.ServerTypes.ST_VARCHAR2); break; default: throw new UnsupportedDataTypeException(column.DASDataType.ToString()); } i++; } try { stringBuilder.AppendFormat("SELECT NULL FROM {0}", dataTable.DBTableName); i = 1; foreach (DASDataColumn column in Table.PrimaryKey) { if (i == 1) { stringBuilder.Append(" WHERE "); } else { stringBuilder.Append(" AND "); } stringBuilder.AppendFormat("{0} = @P{1}", column.ColumnName, i++); } TableDAS.FillDataTable(dataTable, stringBuilder.ToString()); } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } finally { for (var k = 1; k <= Table.PrimaryKey.Length; k++) { TableDAS.RemoveParameter(string.Format("@P{0}", k)); } } if (dataTable.Rows.Count() == 1) { ReturnValue = true; } else if (dataTable.Rows.Count() > 1) { throw new TooManyRowsFoundException(); } return(ReturnValue); }
/// <summary> /// This method overloads the base class method to support DAS specific properties. /// </summary> /// <param name="table">Table to be merged.</param> public void Merge(DASDataTable table) { Merge(table, true, MissingSchemaAction.Error); }
/// <summary> /// This method overloads the base class method to support DAS specific properties. /// </summary> /// <param name="table">Table to be merged.</param> /// <param name="preserveChanges"><c>True</c> means all changes are preserved.</param> public void Merge(DASDataTable table, bool preserveChanges) { Merge(table, preserveChanges, MissingSchemaAction.Error); }