3
I have a field in the database (Seqalteracao) of type timestamp
and need to map it to C# (Entity Framework).
What is the corresponding type in C# for this type in the bank?
public **Tipo** SeqAlteracao { get; set; }
3
I have a field in the database (Seqalteracao) of type timestamp
and need to map it to C# (Entity Framework).
What is the corresponding type in C# for this type in the bank?
public **Tipo** SeqAlteracao { get; set; }
6
You can use the type byte
annotated TimeStamp
[Timestamp]
public byte[] RowVersion { get; set; }
Look at that one tutorial to better understand.
2
The normal and seemingly most obvious would be to use the DateTime
, After all, the goal of both, roughly speaking, is the same, is to point a point in time. Each with a different representation, but the data is the same. And when we talk about data to be processed the representation doesn’t matter, it only matters when it goes out. Then read a timestamp
and play in a DateTime
.
Or don’t do it, because the specific purpose of the type timestamp
SQL Server is actually for versioning and not exactly for saving a point in time. So only use so even if the SQL Server modeling was done wrong and used the wrong type.
The correct types in SQL Server when the intention is to save a time is the datetime
and the datetime2
. Actually even this is not perfect, since the semantics of each of the two and the type of C# do not match.
Be the intention to save a versioning even, use a long
. Some even prefer to create their own kind.
Browser other questions tagged c# sql-server entity-framework type-conversion
You are not signed in. Login or sign up in order to post.
This totorial demonstrated well the use, was exactly what needed, because to use Dataannotations.
– Marco Souza
ah the S is minute [Timestamp]
– Marco Souza
I put minusculo! Thank you!
– Ricardo