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

Asked

Viewed 31 times

1

For example, I have a table where the field in the bank called COD_CLIENTE, but in the model layer it is ID_CLIENTE, how to access this value without changing the name of the in the 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
  • Which framework data persistence?

  • Do you use any ORM or hand-held access to data?

1 answer

1

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

Now I don’t know if you’re using any framework for data persistence. If yes, most of them you can use annotations (data Annotations) telling you which column you want that field to stack in the database.

Example:

 [Table("cliente")]
 Partial Public Class CadastroCliente
 {
   [Column("cliente_id")]
   Public Property codigo As Int32
 }
  • 1

    Good, it just seems that yours is in c# and not in Vb

Browser other questions tagged

You are not signed in. Login or sign up in order to post.