Example #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()));
     }
 }
Example #2
0
        public ConstraintInfo Clone(TableInfo newParent)
        {
            ConstraintInfo ci = ConstraintInfo.GetInstance(newParent);

            ci.ConstraintName     = ConstraintName;
            ci.DataConnectionSpec = DataConnectionSpec;
            ci.OnDeleteAction     = this.OnDeleteAction;
            ci.OnUpdateAction     = this.OnUpdateAction;

            // TODO: is this ok? we're not cloning the references table...
            if (ci.ReferencesTable != ci.Table)
            {
                // self-referential.  no need to clone it.
                Debug.WriteLine("NOT cloning ci.ReferencesTable as it is self-referential");
            }
            else
            {
                // pointing at a different table, clone it
                ci.ReferencesTable = this.ReferencesTable.Clone(true, true, true);
            }

            ci.ReferencesTableName = this.ReferencesTableName;
            ci.SyncAction          = SyncAction;
            ci.Table     = newParent;
            ci.TableName = newParent.TableName;
            foreach (FieldInfo fiSrc in SourceFields)
            {
                ci.SourceFields.Add(fiSrc.Clone(newParent));
            }
            ci.SourceFieldNames = SourceFieldNames.ToList();

            foreach (FieldInfo fiRef in ReferencesFields)
            {
                ci.ReferencesFields.Add(fiRef.Clone(newParent));
            }
            ci.ReferencesFieldNames = ReferencesFieldNames.ToList();

            return(ci);
        }
Example #3
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);
 }