예제 #1
0
        public virtual DataBase AddFK()
        {
            dt = conn.getFK();
            ForeignKey fk              = null;
            string     bangthamchieu   = "";
            string     bangdcthamchieu = "";
            string     cotthamchieu    = "";
            string     cotdcthamchieu  = "";

            if (dt.Rows.Count != 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    if (bangthamchieu != item["referencing_table_name"].ToString() ||
                        bangdcthamchieu != item["referenced_table_name"].ToString())
                    {
                        if (fk != null)
                        {
                            db.ListFK.Add(fk);
                        }

                        bangthamchieu   = item["referencing_table_name"].ToString();
                        cotthamchieu    = item["referencing_column_name"].ToString();
                        bangdcthamchieu = item["referenced_table_name"].ToString();
                        cotdcthamchieu  = item["referenced_column_name"].ToString();

                        fk                   = new ForeignKey();
                        fk.FKName1           = item["constraint_name"].ToString();
                        fk.ReferencedTable1  = standardizing(bangdcthamchieu);
                        fk.ReferencingTable1 = standardizing(bangthamchieu);

                        fk.ReferencedColumn1.Add(standardizing(cotdcthamchieu));
                        fk.ReferencingColumn1.Add(standardizing(cotthamchieu));
                    }
                    else
                    {
                        fk.ReferencedColumn1.Add(standardizing(item["referenced_column_name"].ToString()));
                        fk.ReferencingColumn1.Add(standardizing(item["referencing_column_name"].ToString()));
                    }
                }

                db.ListFK.Add(fk);
            }

            return(db);
        }