mvanella
mvanella

Reputation: 3666

Finding updated entry with Entity Framework Timestamp using code first

One of my models, let's call it "Comment" has a timestamp column/member

I had defined it originally as:

[Required]
public DateTime Timestamp { get; set; }

I had some methods in other parts of my code that would get the latest comments after a specific time, so it would grab all comments with a timestamp greater than some value.

I recently came across an article by Julie Lerman about the timestamp data annotation for entity framework (http://msdn.microsoft.com/en-US/data/jj591583#c_8b121aeb433a4ab19d538bc8c20a58fb) and she suggested using a byte array with the [Timestamp] data annotation for correct storage in the database.

[Timestamp]
public Byte[] Timestamp { get; set; }

I am not sure how to handle finding updated records with the byte array. From what I understand, the system handles timestamp byte arrays by just incrementing them by 1 every time they are updated, but that is a relative value.

What am I missing?

Upvotes: 2

Views: 1398

Answers (1)

Ryan Amies
Ryan Amies

Reputation: 4932

Sounds like you're not using the Timestamp property as a concurrency check but as a standard property. I'd revert back to a DateTime

Upvotes: 2

Related Questions