How to use a table in the bank with different fields of the model layer?

1

For example, I have a table where the field in the database named COD_CLIENTE , but in the model layer it is ID_CLIENTE , how to access that value without changing the name of the model in VB.net ?

Partial Public Class CadastroCliente
    Public Property nome As String
    Public Property contato As String
    Public Property tipo As String
    Public Property ID_CLIENTE As Nullable(Of Integer)

End Class
    
asked by anonymous 28.03.2016 / 22:05

1 answer

1

Strange your question, because if you are using only sql the class is not mapped, ie it does not reflect your database and you can use it normally.

Now I'm not sure if you're using any framework for data persistence. If yes, most of them you can use annotations (data annotations) telling which column you want that field to map to the bank.

Example:

 [Table("cliente")]
 Partial Public Class CadastroCliente
 {
   [Column("cliente_id")]
   Public Property codigo As Int32
 }
    
29.03.2016 / 15:12