示例#1
0
 private bool mapSourceFields(DataSet ds, DataRow dr)
 {
     DataRow[] drSourceFields = ds.Tables["ConstraintSourceFieldInfo"].Select("parent_id = " + dr["id"]);
     if (drSourceFields != null && drSourceFields.Length > 0)
     {
         foreach (DataRow drSrc in drSourceFields)
         {
             SourceFieldNames.Add(drSrc["field_name"].ToString().ToLower());
             foreach (FieldInfo fi in this.Table.Fields)
             {
                 if (fi.Name.ToUpper().Trim() == drSrc["field_name"].ToString().ToUpper().Trim())
                 {
                     SourceFields.Add(fi);
                     //fi.IsForeignKey = true;
                     //fi.ForeignKeyTableName = ReferencesTableName;
                     //fi.ForeignKeyFieldName =
                     break;
                 }
             }
         }
         return(SourceFields.Count > 0);
     }
     else
     {
         throw new InvalidOperationException(getDisplayMember("mapSourceFields", "Constraint {0} is defined with parent_id={1} but no fields were found in ConstraintSourceFieldInfo for it.", dr["constraint_name"].ToString(), dr["id"].ToString()));
     }
 }
示例#2
0
 private bool mapSourceFields(DataSet ds, TableInfo target)
 {
     // rescan dataset for constraint info
     DataRow[] drSourceFields = ds.Tables["ConstraintSourceFieldInfo"].Select("constraint_name = '" + target.TableName + "'");
     if (drSourceFields != null && drSourceFields.Length > 0)
     {
         foreach (DataRow drSrc in drSourceFields)
         {
             SourceFieldNames.Add(drSrc["field_name"].ToString().ToLower());
             foreach (FieldInfo fi in target.Fields)
             {
                 if (fi.Name.ToUpper().Trim() == drSrc["field_name"].ToString().ToUpper().Trim())
                 {
                     SourceFields.Add(fi);
                     //fi.IsForeignKey = true;
                     //fi.ForeignKeyTableName = ReferencesTableName;
                     //fi.ForeignKeyFieldName =
                     break;
                 }
             }
         }
     }
     return(SourceFields.Count > 0);
 }