Representation of an entity in my class

Asked

Viewed 41 times

5

I got that field on the bench: ID_LIBERACAO and in my class of mastery I have so:

[Table("Tabela")]
public class Tabela
[Key]
[DataBaseGenerated(DataBaseGeneratedOption.Identity)]
public int IdLiberacao {get; set; }

Even with the name without the underscore sign, does my class understand that you are referring to the table field? I eliminated all the underscore of the field names and standardized this way. I have no way to test it yet, until I receive the customer’s release.

1 answer

2


Specify the name in the bank, use annotation, see:

[Table("Tabela")]
public class Tabela
[Key]
[DataBaseGenerated(DataBaseGeneratedOption.Identity)]
[Column("ID_LIBERACAO")]
public int IdLiberacao {get; set; }

Reference: Dataannotation

  • So, do I do this for all the columns that I changed the name in the class? I did this for all

  • Yes, this way you will have control of the mapping.

  • Edvaldo, if the name of the attribute in my class is the same as in the bank, I don’t need to use the Column attribute, right? Or if I’ve done it in one, do I have to do it in all? Just one question.

  • You can do only in the cases you want to customize the mapping, do not need to do for everyone.

Browser other questions tagged

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