Ejemplo n.º 1
0
        public override SyncTableRelationList GetRelationsForTables(SyncTableList list, SyncDatabase db)
        {
            string sql = @"select rc.rdb$constraint_name constraint_name, rc.rdb$relation_name child_table,
rc2.rdb$relation_name parent_table,
sg.rdb$field_name child_column, sg2.rdb$field_name parent_column
from rdb$relation_constraints rc
 left join rdb$ref_constraints rr on rr.rdb$constraint_name = rc.rdb$constraint_name
 left join rdb$relation_constraints rc2 on rc2.rdb$constraint_name = rr.rdb$const_name_uq
 left join rdb$index_segments sg on sg.rdb$index_name = rc.rdb$index_name
 left join rdb$index_segments sg2 on sg2.rdb$index_name = rc2.rdb$index_name
where rc.rdb$constraint_type = 'FOREIGN KEY'

union all

select '', table_child, table_parent, '', ''
from sync_table_dep
";

            SyncTableRelationList result = new SyncTableRelationList();

            using (FbCommand cmd = db.CreateCommand() as FbCommand)
            {
                cmd.CommandText = sql;
                using (IDataReader reader = cmd.ExecuteReader())
                    while (reader.Read())
                    {
                        SyncTableRelation rel = new SyncTableRelation();
                        rel.ParentTable   = reader["PARENT_TABLE"].ToString().Trim();
                        rel.ChildTable    = reader["CHILD_TABLE"].ToString().Trim();
                        rel.ParentColumns = new string [] { reader["PARENT_COLUMN"].ToString().Trim() };
                        rel.ChildColumns  = new string[] { reader["CHILD_COLUMN"].ToString().Trim() };
                        result.Add(rel);
                    }
            }

            return(result);
        }
Ejemplo n.º 2
0
 public SyncTableCrossLink(SyncTableRelation rel1, SyncTableRelation rel2)
 {
 }