【译】第11节---数据注解-TimeStamp
TimeStamp属性只能应用于域类的一个字节数组属性。 TimeStamp属性创建一个带有timestamp数据类型的列。Code First在并发检查中自动使用此TimeStamp列。
请看以下示例:
using System.ComponentModel.DataAnnotations; public class Student { public Student() { } public int StudentKey { get; set; } public string StudentName { get; set; } [TimeStamp] public byte[] RowVersion { get; set; } }
如上例所示,TimeStamp属性应用于Student类的Byte[]属性。
因此,Code First将在Student表中创建一个时间戳列RowVersion,如下所示: