首先使用代码在Entity Framework Timestamp中查找更新的条目 [英] Finding updated entry with Entity Framework Timestamp using code first
问题描述
我的一个模型,我们称其为"Comment",其中有一个时间戳列/成员
One of my models, let's call it "Comment" has a timestamp column/member
我最初将其定义为:
[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.
我最近遇到了朱莉·勒曼(Julie Lerman)的一篇有关实体框架的时间戳数据注释的文章(
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; }
我不确定如何处理字节数组查找更新的记录.据我了解,系统通过在每次更新时将时间戳字节数组增加1来处理时间戳字节数组,但这是一个相对值.
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.
我想念什么?
推荐答案
听起来像您不是将 Timestamp
属性用作并发检查,而是将其用作标准属性.我将恢复为 DateTime
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
这篇关于首先使用代码在Entity Framework Timestamp中查找更新的条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!