Example #1
0
 protected virtual SchemaResult SetForeignKey(Table table, Table target, ForeignKeyColumn fk)
 {
     CurrentSchema.AddForeignKey(fk);
     table.RemoveColumn(fk.Name);
     table.AddColumn(fk);
     target.ReferencingForeignKeys = GetReferencingForeignKeysForTable(target.Name);
     table.ForeignKeys             = GetForeignKeysForTable(table.Name);
     if (AutoSave)
     {
         CurrentSchema.Save();
     }
     return(new SchemaResult("ForeignKeyColumn set"));
 }
        public override BAS.ForeignKeyColumn[] GetForeignKeyColumns()
        {
            DataTable foreignKeyData            = GetForeignKeyData(_daoDatabase);
            List <BAS.ForeignKeyColumn> results = new List <BAS.ForeignKeyColumn>();

            foreach (DataRow row in foreignKeyData.Rows)
            {
                BAS.ForeignKeyColumn fk = new BAS.ForeignKeyColumn();
                fk.TableName     = row["ForeignKeyTable"].ToString();
                fk.ReferenceName = row["ForeignKeyName"].ToString();
                fk.Name          = row["ForeignKeyColumn"].ToString();
                fk.ReferencedKey = row["PrimaryKeyColumn"].ToString();

                fk.ReferencedTable = row["PrimaryKeyTable"].ToString();
                results.Add(fk);
            }

            return(results.ToArray());
        }
Example #3
0
        public void SetPropertyName(string columnName, string propertyName)
        {
            List <Column> columns = new List <Column>(Columns);
            Column        toSet   = columns.FirstOrDefault(c => c.Name.Equals(columnName));

            if (toSet != null)
            {
                toSet.PropertyName = propertyName;
                Columns            = columns.ToArray();
            }
            else
            {
                List <ForeignKeyColumn> fks     = new List <ForeignKeyColumn>(ForeignKeys);
                ForeignKeyColumn        toSetFk = fks.FirstOrDefault(c => c.Name.Equals(columnName));
                if (toSetFk != null)
                {
                    toSetFk.PropertyName = propertyName;
                    ForeignKeys          = fks.ToArray();
                }
            }
        }
Example #4
0
 public void WriteReferencingList(ForeignKeyColumn fk)
 {
     Write(fk.RenderListProperty());
 }
Example #5
0
 public void WriteAddToChildDaoCollection(ForeignKeyColumn fk)
 {
     Write(fk.RenderAddToChildDaoCollection());
 }
Example #6
0
 public void WriteForeignKeyColumnProperty(ForeignKeyColumn fk, int num)
 {
     Write(fk.RenderClassProperty(num, Namespace));
 }