IConventionPropertyBase.SetField Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
SetField(FieldInfo, Boolean) |
Obsolete.
Sets the FieldInfo for the underlying CLR field that this property should use. By default, the backing field, if one is found or has been specified, is used when new objects are constructed, typically when entities are queried from the database. Properties are used for all other accesses. This can be changed by calling SetPropertyAccessMode(Nullable<PropertyAccessMode>, Boolean). |
SetField(String, Boolean) |
Sets the underlying CLR field that this property should use.
This may be |
SetField(FieldInfo, Boolean)
Caution
Use SetFieldInfo
Sets the FieldInfo for the underlying CLR field that this property should use.
By default, the backing field, if one is found or has been specified, is used when new objects are constructed, typically when entities are queried from the database. Properties are used for all other accesses. This can be changed by calling 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)
Parameters
- fromDataAnnotation
- Boolean
Indicates whether the configuration was specified using a data annotation.
- Attributes
Applies to
SetField(String, Boolean)
Sets the underlying CLR field that this property should use.
This may be null
for shadow properties or if the backing field for the property is not known.
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
Parameters
- fieldName
- String
The name of the field to use.
- fromDataAnnotation
- Boolean
Indicates whether the configuration was specified using a data annotation.
Returns
The new FieldInfo.
Remarks
Backing fields are normally found by convention. This method is useful for setting backing fields explicitly in cases where the correct field is not found by convention.
By default, the backing field, if one is found or has been specified, is used when new objects are constructed, typically when entities are queried from the database. Properties are used for all other accesses. This can be changed by calling SetPropertyAccessMode(Nullable<PropertyAccessMode>, Boolean).
See Backing fields for more information and examples.
Applies to
Entity Framework