PropertyValues Class

Definition

A collection of all property values for an entity.

Objects of this type can be obtained from CurrentValues, OriginalValues, GetDatabaseValues(), or GetDatabaseValuesAsync(CancellationToken). Once obtained, the objects are usually used in various combinations to resolve optimistic concurrency exceptions signaled by the throwing of a DbUpdateConcurrencyException.

public abstract class PropertyValues
type PropertyValues = class
Public MustInherit Class PropertyValues
Inheritance
PropertyValues

Remarks

See Accessing tracked entities in EF Core for more information.

Constructors

PropertyValues(InternalEntityEntry)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

Properties

EntityType

Gets the underlying entity type for which this object is storing values.

InternalEntry

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

Item[IProperty]

Gets or sets the value of the property.

Item[String]

Gets or sets the value of the property with the specified property name.

Properties

Gets the properties for which this object is storing values.

Methods

Clone()

Creates a clone of the values in this object. Changes made to the new object will not be reflected in this object and vice versa.

GetValue<TValue>(IProperty)

Gets the value of the property just like using the indexed property getter but typed to the type of the generic parameter.

GetValue<TValue>(String)

Gets the value of the property just like using the indexed property getter but typed to the type of the generic parameter.

SetValues(IDictionary<String,Object>)

Sets the values of this object by copying values from the given dictionary.

The keys of the dictionary must match property names. Any key in the dictionary that does not match the name of a property in the entity type will be ignored.

SetValues(Object)

Sets the values of this object by copying values from the given object.

The given object can be of any type. Any property on the object with a name that matches a property name in the entity type and can be read will be copied. Other properties will be ignored. This allows, for example, copying of properties from simple Data Transfer Objects (DTOs).

SetValues(PropertyValues)

Sets the values of this object by reading values from another PropertyValues object.

The other object must be based on the same type as this object, or a type derived from the type for this object.

SetValues<TProperty>(IDictionary<String,TProperty>)

Sets the values of this object by copying values from the given dictionary.

The keys of the dictionary must match property names. Any key in the dictionary that does not match the name of a property in the entity type will be ignored.

ToObject()

Creates an instance of the entity type and sets all its properties using the values from this object.

TryGetValue<TValue>(String, TValue)

Try to gets the value of the property just like using the indexed property getter but typed to the type of the generic parameter. If property exists it return the value into the out parameter, otherwise the default value of TValue

Applies to