Ejemplo n.º 1
0
        public void CreateForeignKey(ForeignKeyDescriptor fk)
        {
            DbCommand cmd = con.CreateCommand();

            cmd.Transaction = trx;

            try
            {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText =
                    "ALTER TABLE " +
                    reflectTableName(fk.sourceType) +
                    " ADD FOREIGN KEY (" + fk.sourceFieldName + ")" +
                    " REFERENCES " + reflectTableName(fk.targetType) +
                    "(" + fk.targetFieldName + ")";

                if (settings.sqlLog != null)
                {
                    settings.sqlLog.WriteLine("== START " +
                                              DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss") + " ===");
                    settings.sqlLog.WriteLine(cmd.CommandText);
                    settings.sqlLog.WriteLine("== END =========================");
                    settings.sqlLog.Flush();
                }

                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                if (cmd.Transaction != null)
                {
                    cmd.Transaction.Rollback();
                }
                con.Close();
                con.Dispose();
                throw;
            }
            finally
            {
                cmd.Dispose();
            }
        }
Ejemplo n.º 2
0
 public void CreateForeignKey(ForeignKeyDescriptor fk)
 {
     throw new Exception("The method or operation is not implemented.");
 }