Ejemplo n.º 1
0
 protected override object GetPropertyValue(object obj, string name, Table table, Row row)
 {
     DataRow dataRow = (DataRow)obj;
     if (dataRow.IsNull(name))
     {
         return null;
     }
     return dataRow[name];
 }
Ejemplo n.º 2
0
 protected override object GetPropertyValue(object obj, string name, Table table, Row row)
 {
     IDictionary dictionary = (IDictionary)obj;
     if (!dictionary.Contains(name))
     {
         return null;
     }
     return dictionary[name];
 }
Ejemplo n.º 3
0
 public PropertyInfo GetPropertyInfo(string columnName, Type type, Table table, Row row)
 {
     try
     {
         return this[type][columnName];
     }
     catch (Exception e)
     {
         throw new ConfigException(e, "M_Fixture_Temp_ObjectFactory_NoSuchProperty", columnName, type, table, row);
     }
 }
Ejemplo n.º 4
0
 public DataTable GetMetaData(Table table)
 {
     string[] tableNameAndDatabaseName = SplitTableNameAndDatabaseName(table.Name);
     Use(tableNameAndDatabaseName[1]);
     try
     {
         DataTable metaData = GetMetaDataTable(tableNameAndDatabaseName[0]);
         metaData.TableName = tableNameAndDatabaseName[0];
         return metaData;
     }
     catch (Exception e)
     {
         throw new ConfigException(e, "M_Fixture_Temp_Database_GetMetaData", tableNameAndDatabaseName[0], table);
     }
 }
Ejemplo n.º 5
0
 private static void UpdateColumnTypes(Database database, Table table)
 {
     DataTable metaData = database.GetMetaData(table);
     foreach (Column column in table.Columns)
     {
         if (column != null)
         {
             DataColumn dataColumn = metaData.Columns[column.Name];
             if (dataColumn == null)
             {
                 throw new ConfigException("M_Fixture_Temp_DatabaseOperator_Column_NotFound",
                     metaData.TableName, column.Name, table);
             }
             if (column.Type == null && column.ComponentType == null)
             {
                 column.SetType(dataColumn.DataType);
             }
         }
     }
 }
Ejemplo n.º 6
0
 internal Table CreateTable(string tableName)
 {
     Table table = null;
     tables.TryGetValue(tableName, out table);
     if (table == null)
     {
         table = new Table(this, tableName);
         tables[tableName] = table;
         tablesWithAliases[tableName] = table;
         int atIndex = tableName.IndexOf('@');
         if (atIndex > -1)
         {
             tablesWithAliases[tableName.Substring(0, atIndex)] = table;
         }
         tableNames.Add(tableName);
     }
     return table;
 }
Ejemplo n.º 7
0
 // FIXME : DataTableValidator の機能が一部こっちに入っていてきれいに役割分担できていないのでイマイチ。
 public DataTable Select(List<string> keyColumns, DataTable keyTable, Table tableInfo)
 {
     Use(keyTable);
     string queryPrefix = GetQueryPrefixForSelect(keyTable);
     DataTable resultTable = new DataTable(keyTable.TableName);
     List<Row> rowInfo = tableInfo.Rows;
     int rowIndex = 0;
     foreach (DataRow keyRow in keyTable.Rows)
     {
         DbCommand command = connection.CreateCommand();
         Select(command, keyColumns, keyTable, keyRow, resultTable, tableInfo, rowInfo[rowIndex++], queryPrefix);
     }
     return resultTable;
 }
Ejemplo n.º 8
0
        // FIXME : この処理は本当は DataTableValidator でやるべき
        private DataRow SelectResultRow(DataTable result, DataRow keyRow, Table tableInfo, Row rowInfo, List<string> keyColumns)
        {
            int rowCount = result.Rows.Count;
            if (rowInfo.Deleted)
            {
                if (rowCount == 0)
                {
                    return null;
                }
                else
                {
                    Assertie.Fail("M_Fixture_Temp_DatabaseValidator_UnexpectedData", result.TableName, tableInfo, rowInfo, ToString(keyColumns, keyRow));
                }
            }

            if (rowCount == 0)
            {
                string message = (keyColumns.Count == result.Columns.Count) ?
                    "M_Fixture_Temp_DatabaseValidator_NotFound_With_Comment" :
                    "M_Fixture_Temp_DatabaseValidator_NotFound";
                Assertie.Fail(message, result.TableName, tableInfo, rowInfo, ToString(keyColumns, keyRow));
            }

            if (rowCount > 1)
            {
                Assertie.Fail("M_Fixture_Temp_DatabaseValidator_OneMoreData", result.TableName, tableInfo, rowInfo, ToString(keyColumns, keyRow));
            }

            return result.Rows[0];
        }
Ejemplo n.º 9
0
 private void Select(DbCommand command, List<string> keyColumns, DataTable keyTable, DataRow keyRow, DataTable resultTable, Table tableInfo, Row rowInfo, string queryPrefix)
 {
     SetQueryString(keyTable, keyRow, command, queryPrefix, keyColumns);
     DataTable result = ExecuteQuery(command);
     result.TableName = keyTable.TableName;
     DataRow source = SelectResultRow(result, keyRow, tableInfo, rowInfo, keyColumns);
     if (resultTable.Columns.Count == 0 && source != null)
     {
         foreach(DataColumn column in source.Table.Columns)
         {
             resultTable.Columns.Add(new DataColumn(column.ColumnName, column.DataType));
         }
     }
     DataRow destination = resultTable.NewRow();
     Copy(source, destination);
     resultTable.Rows.Add(destination);
 }
Ejemplo n.º 10
0
 private void InsertRow(DataTable table, DbCommand command, DataRow row, Table tableInfo, Row rowInfo)
 {
     try
     {
         command.Parameters.Clear();
         foreach (DataColumn column in table.Columns)
         {
             AddParameter(command, column.ColumnName, column.DataType, row[column]);
         }
         ExecuteNonQuery(command);
     }
     catch (Exception e)
     {
         throw new ConfigException(e, "M_Fixture_Temp_Database_InsertRow", table.TableName, tableInfo, rowInfo);
     }
 }
Ejemplo n.º 11
0
 private void Delete(DataTable table, DataRow row, Table tableInfo, Row rowInfo)
 {
     try
     {
         DbCommand command = connection.CreateCommand();
         String queryPrefix = "delete from " + table.TableName + " where ";
         List<string> columnNames = new List<string>();
         foreach (DataColumn column in table.Columns)
         {
             columnNames.Add(column.ColumnName);
         }
         SetQueryString(table, row, command, queryPrefix, columnNames);
         ExecuteNonQuery(command);
     }
     catch (Exception e)
     {
         throw new ConfigException(e, "M_Fixture_Temp_Database_DeleteRow", table.TableName, tableInfo, rowInfo);
     }
 }
Ejemplo n.º 12
0
 private DbCommand CreateInsertCommand(DataTable table, Table tableInfo)
 {
     try
     {
         StringBuilder sql = new StringBuilder();
         sql.Append("insert into ").Append(table.TableName);
         sql.Append(GetColumnList(table.Columns));
         sql.Append(GetValueList(table.Columns));
         return connection.CreateCommand(sql.ToString());
     }
     catch (Exception e)
     {
         throw new ConfigException(e, "M_Fixture_Temp_Database_CreateInsertCommand", table.TableName, tableInfo);
     }
 }
Ejemplo n.º 13
0
 internal void Insert(DataTable table, Table tableInfo)
 {
     try
     {
         SetEnabledIdentityInsert(true, table.TableName);
         DbCommand command = CreateInsertCommand(table, tableInfo);
         List<Row> rowInfo = tableInfo.Rows;
         int rowIndex = 0;
         foreach (DataRow row in table.Rows)
         {
             InsertRow(table, command, row, tableInfo, rowInfo[rowIndex++]);
         }
     }
     finally
     {
         SetEnabledIdentityInsert(false, table.TableName);
     }
 }
Ejemplo n.º 14
0
 internal void Delete(DataTable table, Table tableInfo)
 {
     List<Row> rowInfo = tableInfo.Rows;
     int rowIndex = 0;
     foreach (DataRow row in table.Rows)
     {
         Delete(table, row, tableInfo, rowInfo[rowIndex++]);
     }
 }
Ejemplo n.º 15
0
 private void ChangeTable(Table table)
 {
     this.table = table;
     this.columns = null;
     this.columnNameRowIndex = -1;
     this.columnValueRowIndex = -1;
     this.values = null;
 }
Ejemplo n.º 16
0
 private static void InitializeSearchKey(Table table)
 {
     if (HasSearchKeyColumn(table.Columns))
     {
         return;
     }
     foreach (Column column in table.Columns)
     {
         if (column != null)
         {
             column.IsSearchKey = true;
         }
     }
 }