How to find out the type of relationship between two tables

0

Hello, people

I would like to know a way, or rather, if I can find through a SELECT, the type of relationship between two tables wanted me to return.

SELECT TABELA_PRINCIPAL, TABELA_RELACIONADA, COLUNA_PRINCIPAL, COLUNA_RELACIONADA, TIPO_RELACIONAMENTO FROM (...)

in TIPO_RELACIONAMENTO could come as a flag (1 = One for One, 2 = One for many and 3 for Many, 4 for no relationship). This is for MySql database and Sql Server.

I am developing a particular Models class generator in Console Application . Maybe you might ask, "Why not use Code First with Reverse Engineering?" Because I'm doing a private one because in this my Console Application I can handle the name of the class and the name of the columns for reasons of convention, Code First with Reverse Engineering does not do this: it simply generates the classes from the database with the name of the database tables, and depending on the name of the tables, every poop in the model comes out, you know?

My generator is already generating the Access layer with Repository Pattern Generic, Models with Mappers and DataAnotation , all automatic, only they simply do not come with relationships within the Mappers classes. I needed this.

I'm doing the nail because I still can not know how the process of reading the schemas and relationship of the bank through Fluent Api is done.

Who can help? I'm grateful.

    
asked by anonymous 18.08.2015 / 07:06

0 answers