IConventionPropertyBase.SetField 方法

定義

多載

SetField(FieldInfo, Boolean)
已淘汰.

FieldInfo設定此屬性應該使用之基礎 CLR 欄位的 。

根據預設,如果找到或已指定支援欄位,則會在建構新物件時使用,通常是從資料庫查詢實體時。 屬性會用於所有其他存取。 您可以藉由呼叫 SetPropertyAccessMode(Nullable<PropertyAccessMode>, Boolean) 來變更。

SetField(String, Boolean)

設定此屬性應該使用的基礎 CLR 欄位。 這可能 null 適用于陰影屬性,或屬性的支援欄位未知。

SetField(FieldInfo, Boolean)

警告

Use SetFieldInfo

FieldInfo設定此屬性應該使用之基礎 CLR 欄位的 。

根據預設,如果找到或已指定支援欄位,則會在建構新物件時使用,通常是從資料庫查詢實體時。 屬性會用於所有其他存取。 您可以藉由呼叫 SetPropertyAccessMode(Nullable<PropertyAccessMode>, Boolean) 來變更。

public void SetField (System.Reflection.FieldInfo fieldInfo, bool fromDataAnnotation = false);
[System.Obsolete("Use SetFieldInfo")]
public virtual void SetField (System.Reflection.FieldInfo fieldInfo, bool fromDataAnnotation = false);
[System.Obsolete("Use SetFieldInfo")]
public virtual void SetField (System.Reflection.FieldInfo? fieldInfo, bool fromDataAnnotation = false);
abstract member SetField : System.Reflection.FieldInfo * bool -> unit
[<System.Obsolete("Use SetFieldInfo")>]
abstract member SetField : System.Reflection.FieldInfo * bool -> unit
override this.SetField : System.Reflection.FieldInfo * bool -> unit
Public Sub SetField (fieldInfo As FieldInfo, Optional fromDataAnnotation As Boolean = false)
Public Overridable Sub SetField (fieldInfo As FieldInfo, Optional fromDataAnnotation As Boolean = false)

參數

fieldInfo
FieldInfo

FieldInfo要使用的基礎 CLR 欄位的 。

fromDataAnnotation
Boolean

指出是否使用資料批註來指定組態。

屬性

適用於

SetField(String, Boolean)

設定此屬性應該使用的基礎 CLR 欄位。 這可能 null 適用于陰影屬性,或屬性的支援欄位未知。

public virtual System.Reflection.FieldInfo SetField (string fieldName, bool fromDataAnnotation = false);
public System.Reflection.FieldInfo? SetField (string? fieldName, bool fromDataAnnotation = false);
abstract member SetField : string * bool -> System.Reflection.FieldInfo
override this.SetField : string * bool -> System.Reflection.FieldInfo
abstract member SetField : string * bool -> System.Reflection.FieldInfo
Public Overridable Function SetField (fieldName As String, Optional fromDataAnnotation As Boolean = false) As FieldInfo
Public Function SetField (fieldName As String, Optional fromDataAnnotation As Boolean = false) As FieldInfo

參數

fieldName
String

要使用的功能變數名稱。

fromDataAnnotation
Boolean

指出是否使用資料批註來指定組態。

傳回

新的 FieldInfo

備註

備份欄位通常是依照慣例找到。 如果慣例找不到正確的欄位,這個方法有助於明確設定支援欄位。

根據預設,如果找到或已指定支援欄位,則會在建構新物件時使用,通常是從資料庫查詢實體時。 屬性會用於所有其他存取。 您可以藉由呼叫 SetPropertyAccessMode(Nullable<PropertyAccessMode>, Boolean) 來變更。

如需詳細資訊和範例 ,請參閱支援欄位

適用於