码迷,mamicode.com
首页 > 其他好文 > 详细

Entity Framework Code-First(9.2):DataAnnotations - TimeStamp Attribute

时间:2016-07-05 17:06:28      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

DataAnnotations - TimeStamp Attribute:

TimeStamp attribute can be applied to only one byte array property of a domain class. TimeStamp attribute creates a column with timestamp datatype. Code-First automatically use this TimeStamp column in concurrency check.

Consider the following example.

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; }
}
     

 

As you can see in the above example, TimeStamp attribute is applied to Byte[] property of the Student class. So, Code First will create a timestamp column RowVersion in the Student table as shown below.

技术分享

Entity Framework Code-First(9.2):DataAnnotations - TimeStamp Attribute

标签:

原文地址:http://www.cnblogs.com/purplefox2008/p/5644109.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!