Ejemplo n.º 1
0
		internal virtual string DropPrimaryKey(PrimaryKey key)
		{
			string fields="";
			foreach (string str in key.Fields)
				fields+=str+",";
			return String.Format(DropPrimaryKeyString,key.Name,fields.Substring(0,fields.Length-1));
		}
Ejemplo n.º 2
0
		internal string CreatePrimaryKey(PrimaryKey key)
		{
			string ret="";
			foreach(string str in key.Fields)
			{
				ret+=str+",";
			}
			return string.Format(CreatePrimaryKeyString,key.Name,ret.Substring(0,ret.Length-1));
		}
Ejemplo n.º 3
0
 internal void RecurDropPK(PrimaryKey pk, Dictionary<PrimaryKey, List<ForeignKey>> pks, Dictionary<ForeignKey, PrimaryKey> fks, ref List<string> queries, Connection conn)
 {
     string query;
     bool add = true;
     query = conn.queryBuilder.DropPrimaryKey(pk);
     if (query.Contains("\n"))
     {
         foreach (string str in query.Split('\n'))
         {
             if (str.Trim().Length > 0)
             {
                 if (queries.Contains(str))
                 {
                     add = false;
                     break;
                 }
             }
         }
     }
     else
         add = !queries.Contains(query);
     if (add)
     {
         foreach (ForeignKey fk in pks[pk])
         {
             if (!fks.ContainsKey(fk))
             {
                 query = conn.queryBuilder.DropForeignKey(fk.InternalTable, fk.ExternalTable, fk.ExternalFields[0], fk.InternalFields[0]);
                 if (query.Contains("\n"))
                     queries.AddRange(query.Split('\n'));
                 else
                     queries.Add(query);
             }
             else
             {
                 if (fks[fk].Name != fk.ExternalTable)
                     RecurDropPK(fks[fk], pks, fks, ref queries, conn);
                 query = conn.queryBuilder.DropForeignKey(fk.InternalTable, fk.ExternalTable, fk.ExternalFields[0], fk.InternalFields[0]);
                 if (query.Contains("\n"))
                     queries.AddRange(query.Split('\n'));
                 else
                     queries.Add(query);
             }
         }
         query = conn.queryBuilder.DropPrimaryKey(pk);
         if (query.Contains("\n"))
             queries.AddRange(query.Split('\n'));
         else
             queries.Add(query);
     }
 }