ColumnAttribute.IsDbGenerated 属性

定义

获取或设置一个值,该值指示列是否包含数据库自动生成的值。

public:
 property bool IsDbGenerated { bool get(); void set(bool value); };
public bool IsDbGenerated { get; set; }
member this.IsDbGenerated : bool with get, set
Public Property IsDbGenerated As Boolean

属性值

默认值 = false

示例

[Column(Storage="_OrderID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public int OrderID
{
    get
    {
        return this._OrderID;
    }
    set
    {
        if ((this._OrderID != value))
        {
            this.OnOrderIDChanging(value);
            this.SendPropertyChanging();
            this._OrderID = value;
            this.SendPropertyChanged("OrderID");
            this.OnOrderIDChanged();
        }
    }
}
<Column(Storage:="_OrderID", AutoSync:=AutoSync.OnInsert, DbType:="Int NOT NULL IDENTITY", IsPrimaryKey:=true, IsDbGenerated:=true)>  _
Public Property OrderID() As Integer
    Get
        Return Me._OrderID
    End Get
    Set
        If ((Me._OrderID = value)  _
                    = false) Then
            Me.OnOrderIDChanging(value)
            Me.SendPropertyChanging
            Me._OrderID = value
            Me.SendPropertyChanged("OrderID")
            Me.OnOrderIDChanged
        End If
    End Set
End Property

注解

IsDbGenerated 成员在插入数据行后立即同步,成员在完成后可用 SubmitChanges

注意

如果列包含主键值,并且你指定IsDbGeneratedtrue,则还应使用 IDENTITY 修饰符添加 DbType 属性。

适用于