共用方式為


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 屬性。

適用於