private string CreateFinalSelect(bool forinsert) { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); foreach (Object o in this._schema.Rows) { DataRow dataRow = (DataRow)o; string text = (string)dataRow["BaseTableName"]; if (text != null && text.Length != 0) { string text2 = this.Quote(dataRow["ColumnName"].ToString()); string parameterName = MySqlCommandBuilder.GetParameterName(dataRow["ColumnName"].ToString()); if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(text2); if ((bool)dataRow["IsKey"]) { if (stringBuilder2.Length > 0) { stringBuilder2.Append(" AND "); } stringBuilder2.Append("(" + text2 + "="); if (forinsert) { if ((bool)dataRow["IsAutoIncrement"]) { stringBuilder2.Append("last_insert_id()"); } else if ((bool)dataRow["IsKey"]) { stringBuilder2.Append(this.marker + parameterName); } } else { stringBuilder2.Append(this.marker + "Original_" + parameterName); } stringBuilder2.Append(")"); } } } return(string.Concat(new string[] { "SELECT ", stringBuilder.ToString(), " FROM ", this.TableName, " WHERE ", stringBuilder2.ToString() })); }
private MySqlParameter CreateParameter(DataRow row, bool Original) { string parameterName = MySqlCommandBuilder.GetParameterName(row["ColumnName"].ToString()); MySqlDbType type = (MySqlDbType)row["ProviderType"]; MySqlParameter result; if (Original) { result = new MySqlParameter(string.Format("{0}Original_{1}", this.marker, parameterName), type, (ParameterDirection)1, (string)row["ColumnName"], (DataRowVersion)256, DBNull.Value); } else { result = new MySqlParameter(string.Format("{0}{1}", this.marker, parameterName), type, (ParameterDirection)1, (string)row["ColumnName"], (DataRowVersion)512, DBNull.Value); } return(result); }