diff --git a/at/fos/ermodel/gui/C4.java b/at/fos/ermodel/gui/C4.java index 08b2483..331bc3b 100644 --- a/at/fos/ermodel/gui/C4.java +++ b/at/fos/ermodel/gui/C4.java @@ -452,7 +452,30 @@ public class C4 { } } + /* + public static string convertSqlToCSharp(string sqlStatement) + { + // Split the SQL statement by spaces and identify the foreign key keywords + string[] words = sqlStatement.Split(' '); + int index = Array.IndexOf(words, "FOREIGN") + 1; + // Extract the table names and key names from the SQL statement + string primaryTable = words[index - 3]; + string primaryKey = words[index - 1]; + string foreignTable = words[index + 2]; + string foreignKey = words[index + 4]; + + // Generate the C# EF Core code based on the extracted information + string csharpCode = "modelBuilder.Entity<" + foreignTable + ">()\n"; + csharpCode += ".HasOne(" + foreignTable.ToLower() + " => " + foreignTable.ToLower() + "." + foreignKey + ")\n"; + csharpCode += ".WithMany()\n"; + csharpCode += ".HasForeignKey(" + foreignTable.ToLower() + " => " + foreignTable.ToLower() + "." + foreignKey + ");\n"; + + return csharpCode; + } + TODO: use function + + */ this.sqlScript.append("\n/* TODO: foreign keys-#################################################\n"); for (T1 table : this.tables) {