zoukankan      html  css  js  c++  java
  • Entity Framework Code-First(9.2):DataAnnotations

    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.

    dataannotations TimeStamp attribute

  • 相关阅读:
    有一个双重模板化的错误实现
    非类型模板参数
    C++模板
    初始化列表initializer_list
    C++类型转换
    const引用和constexpr
    逆元
    卡特兰数
    最短路问题
    Android打印机效果的闪屏
  • 原文地址:https://www.cnblogs.com/purplefox2008/p/5644109.html
Copyright © 2011-2022 走看看