aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-12-23 09:34:03 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-12-23 09:34:03 +0200
commit5bec920df45bb79e5912a97f2d0afc1a849adbd2 (patch)
treea0a4a7b62df4bae64b4fb45760f445baad21f4e4 /Software/Visual_Studio/Tango.Core
parente0b0859f62924d38c8cd7ac9975303c4bfb08624 (diff)
downloadTango-5bec920df45bb79e5912a97f2d0afc1a849adbd2.tar.gz
Tango-5bec920df45bb79e5912a97f2d0afc1a849adbd2.zip
Fixed some issues with observables generator.
Diffstat (limited to 'Software/Visual_Studio/Tango.Core')
-rw-r--r--Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs b/Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs
index 0f1193c6c..620fe9dbc 100644
--- a/Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs
+++ b/Software/Visual_Studio/Tango.Core/Components/DataBaseDescriptionsHelper.cs
@@ -18,6 +18,12 @@ namespace Tango.Core.Components
public String ColumnDescription { get; set; }
}
+ public class ForeignKeyDescription
+ {
+ public String TableName { get; set; }
+ public String ColumnName { get; set; }
+ }
+
public static List<DbDescription> GetDescriptions(DbConnection connection)
{
List<DbDescription> dbDescriptions = new List<DbDescription>();
@@ -67,5 +73,30 @@ ORDER BY t.name, c.colorder";
return dbDescriptions;
}
+
+ public static List<ForeignKeyDescription> GetForeignKeys(DbConnection connection)
+ {
+ List<ForeignKeyDescription> keys = new List<ForeignKeyDescription>();
+
+ var command = connection.CreateCommand();
+ command.CommandText = "SELECT a.TABLE_NAME, a.COLUMN_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS b JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE a ON a.CONSTRAINT_CATALOG = b.CONSTRAINT_CATALOG AND a.CONSTRAINT_NAME = b.CONSTRAINT_NAME";
+
+ DataTable table = new DataTable();
+ table.Load(command.ExecuteReader());
+
+ foreach (var row in table.Rows.OfType<DataRow>())
+ {
+ String table_name = row.ItemArray.GetValue(0).ToString();
+ String column_name = row.ItemArray.GetValue(1).ToString();
+
+ keys.Add(new ForeignKeyDescription()
+ {
+ TableName = table_name,
+ ColumnName = column_name
+ });
+ }
+
+ return keys;
+ }
}
}