I want to retrieve each column name and data type then check if the columns is foreign key then query they key table of that relation !!! could be done ?? I googled for 3 days I know that I have to use Mappping model OR Reflection or both ,,,, but i cant do it .
I will simplify what i need assuming :
TABLE1 hase foreign key( COL3) refer to the primary key (COL1) in TABLE0 :
-
iterate TABLE1 Columns check EACH columns if it is a foreign key ( also get its data type)
-
Get the relation to determine the associated table(TABLE0)
-
retrieve the primary key tables (TABLE0)
I got it
I make a function that return the type of each foreign key and the related table class type
But I still need to retrieve the data from those related table .
I mean how to create an instance of the class from its MetaType variable?