AssociationAttribute.ThisKey 屬性

定義

取得或設定實體類別的成員,表示關聯這一端的索引鍵值。

C#
public string ThisKey { get; set; }

屬性值

預設 = 包含類別的 ID。

範例

C#
[Association(Name="FK_CustomerCustomerDemo", Storage="_CustomerDemographic", ThisKey="CustomerTypeID", IsForeignKey=true)]
public CustomerDemographic CustomerDemographic
{
    get
    {
        return this._CustomerDemographic.Entity;
    }
    set
    {
        CustomerDemographic previousValue = this._CustomerDemographic.Entity;
        if (((previousValue != value)
                    || (!this._CustomerDemographic.HasLoadedOrAssignedValue )))
        {
            this.SendPropertyChanging();
            if ((previousValue != null))
            {
                this._CustomerDemographic.Entity = null;
                previousValue.CustomerCustomerDemos.Remove(this);
            }
            this._CustomerDemographic.Entity = value;
            if ((value != null))
            {
                value.CustomerCustomerDemos.Add(this);
                this._CustomerTypeID = value.CustomerTypeID;
            }
            else
            {
                this._CustomerTypeID = default(string);
            }
            this.SendPropertyChanged("CustomerDemographic");
        }
    }
}

備註

針對多個成員,請使用逗號分隔清單。

索引鍵不需要符合主鍵或外鍵,但會假設) 的用戶狀態基數 (0-1 EntityRef<TEntity> 或 0-n EntitySet<TEntity>

適用於

產品 版本
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1