11
I’m using the Dapper which is a micro ORM used to map objects according to the database tables following the relational model. Therefore, I have some doubts regarding the mapping and the structure of the classes.
To illustrate the situation I created two classes representing two tables in my database, the two classes are Cliente
and Telefone
, follows the code:
Client class:
public class Cliente
{
int IdCliente {get; set;}
string Nome {get; set;}
}
Telephone class:
public class Telefone
{
int IdTelefone {get; set;}
int IdCliente {get; set;}
string Numero {get; set;}
}
The relationship of these two classes should represent a 1:N relationship (one for many), i.e., a customer may have multiple phone numbers.
Doubts
- This current class structure conforms to Dapper for him to do the relational mapping?
- There are other structures that I can follow according to the scenario above?
- What would an appointment with a
inner join
to obtain the following fieldsNome
(Client) andNumero
(Telephone)?
I believe you can find the answer you are looking for through this article written by Macoratti. http://www.macoratti.net/15/12/adn_dapper1.htm I did not add the full answer to contemplate the author of the article.
– Leandro Araujo