EntityEntry EntityEntry Class

Definition

Provides access to change tracking information and operations for a given entity.

Instances of this class are returned from methods when using the ChangeTracker API and it is not designed to be directly constructed in your application code.

public class EntityEntry : IInfrastructure<InternalEntityEntry>
Public Class EntityEntry
    Implements IInfrastructure(Of InternalEntityEntry)
Inheritance
System.ObjectSystem.Object
EntityEntryEntityEntry
Implements

Inherited Members

System.Object

System.Object.ToString()System.Object.ToString()
System.Object.Equals(System.Object)System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()System.Object.GetHashCode()
System.Object.GetType()System.Object.GetType()
System.Object.MemberwiseClone()System.Object.MemberwiseClone()

Constructors

EntityEntry(InternalEntityEntry) EntityEntry(InternalEntityEntry)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

public EntityEntry(InternalEntityEntry internalEntry)
Public Sub New(internalEntry As InternalEntityEntry)
Parameters

Properties

Collections Collections

Provides access to change tracking information and loading information for all collection navigation properties of this entity.

public virtual IEnumerable<CollectionEntry> Collections { get; }
Public Overridable ReadOnly Property Collections As IEnumerable(Of CollectionEntry)
Value
System.Collections.Generic.IEnumerable<CollectionEntry> System.Collections.Generic.IEnumerable(Of CollectionEntry)

Context Context

Gets the context that is tracking the entity.

public virtual DbContext Context { get; }
Public Overridable ReadOnly Property Context As DbContext

CurrentValues CurrentValues

Gets the current property values for this entity.

public virtual PropertyValues CurrentValues { get; }
Public Overridable ReadOnly Property CurrentValues As PropertyValues
Value
PropertyValues PropertyValues

The current values.

Entity Entity

Gets the entity being tracked by this entry.

public virtual object Entity { get; }
Public Overridable ReadOnly Property Entity As Object
Value
System.Object System.Object

InternalEntry InternalEntry

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

protected virtual InternalEntityEntry InternalEntry { get; }
Protected Overridable ReadOnly Property InternalEntry As InternalEntityEntry

IsKeySet IsKeySet

Gets a value indicating if the key values of this entity have been assigned a value. False if one or more of the key properties is assigned null or the CLR default, otherwise true.

public virtual bool IsKeySet { get; }
Public Overridable ReadOnly Property IsKeySet As Boolean
Value
System.Boolean System.Boolean

Members Members

Provides access to change tracking information and operations for all properties and navigation properties of this entity.

public virtual IEnumerable<MemberEntry> Members { get; }
Public Overridable ReadOnly Property Members As IEnumerable(Of MemberEntry)
Value
System.Collections.Generic.IEnumerable<MemberEntry> System.Collections.Generic.IEnumerable(Of MemberEntry)

Metadata Metadata

Gets the metadata about the shape of the entity, its relationships to other entities, and how it maps to the database.

public virtual IEntityType Metadata { get; }
Public Overridable ReadOnly Property Metadata As IEntityType

Navigations Navigations

Provides access to change tracking information and operations for all navigation properties of this entity.

public virtual IEnumerable<NavigationEntry> Navigations { get; }
Public Overridable ReadOnly Property Navigations As IEnumerable(Of NavigationEntry)
Value
System.Collections.Generic.IEnumerable<NavigationEntry> System.Collections.Generic.IEnumerable(Of NavigationEntry)

OriginalValues OriginalValues

Gets the original property values for this entity. The original values are the property values as they were when the entity was retrieved from the database.

public virtual PropertyValues OriginalValues { get; }
Public Overridable ReadOnly Property OriginalValues As PropertyValues
Value
PropertyValues PropertyValues

The original values.

Properties Properties

Provides access to change tracking information and operations for all properties of this entity.

public virtual IEnumerable<PropertyEntry> Properties { get; }
Public Overridable ReadOnly Property Properties As IEnumerable(Of PropertyEntry)
Value
System.Collections.Generic.IEnumerable<PropertyEntry> System.Collections.Generic.IEnumerable(Of PropertyEntry)

References References

Provides access to change tracking information and loading information for all reference (i.e. non-collection) navigation properties of this entity.

public virtual IEnumerable<ReferenceEntry> References { get; }
Public Overridable ReadOnly Property References As IEnumerable(Of ReferenceEntry)
Value
System.Collections.Generic.IEnumerable<ReferenceEntry> System.Collections.Generic.IEnumerable(Of ReferenceEntry)

State State

Gets or sets that state that this entity is being tracked in.

When setting the state, the entity will always end up in the specified state. For example, if you change the state to Deleted the entity will be marked for deletion regardless of its current state. This is different than calling Remove(TEntity) where the entity will be disconnected (rather than marked for deletion) if it is in the Added state.

public virtual EntityState State { get; set; }
Public Overridable Property State As EntityState

Methods

Collection(String) Collection(String)

Provides access to change tracking and loading information for a collection navigation property that associates this entity to a collection of another entities.

public virtual CollectionEntry Collection(string navigationPropertyName)
Public Overridable Function Collection(navigationPropertyName As String) As CollectionEntry
Parameters
navigationPropertyName
System.String System.String

The name of the navigation property.

Returns

An object that exposes change tracking information and operations for the given navigation property.

GetDatabaseValues() GetDatabaseValues()

Queries the database for copies of the values of the tracked entity as they currently exist in the database. If the entity is not found in the database, then null is returned.

Note that changing the values in the returned dictionary will not update the values in the database.

public virtual PropertyValues GetDatabaseValues()
Public Overridable Function GetDatabaseValues As PropertyValues
Returns

The store values, or null if the entity does not exist in the database.

GetDatabaseValuesAsync(CancellationToken) GetDatabaseValuesAsync(CancellationToken)

Queries the database for copies of the values of the tracked entity as they currently exist in the database. If the entity is not found in the database, then null is returned.

Note that changing the values in the returned dictionary will not update the values in the database.

Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.

public virtual Task<PropertyValues> GetDatabaseValuesAsync(CancellationToken cancellationToken = null)
Public Overridable Function GetDatabaseValuesAsync(cancellationToken As CancellationToken = Nothing) As Task(Of PropertyValues)
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task<PropertyValues> System.Threading.Tasks.Task(Of PropertyValues)

A task that represents the asynchronous operation. The task result contains the store values, or null if the entity does not exist in the database.

Member(String) Member(String)

Provides access to change tracking information and operations for a given property or navigation property of this entity.

public virtual MemberEntry Member(string propertyName)
Public Overridable Function Member(propertyName As String) As MemberEntry
Parameters
propertyName
System.String System.String

The property to access information and operations for.

Returns

An object that exposes change tracking information and operations for the given property.

Navigation(String) Navigation(String)

Provides access to change tracking information and operations for a given navigation property of this entity.

public virtual NavigationEntry Navigation(string propertyName)
Public Overridable Function Navigation(propertyName As String) As NavigationEntry
Parameters
propertyName
System.String System.String

The property to access information and operations for.

Returns

An object that exposes change tracking information and operations for the given property.

Property(String) Property(String)

Provides access to change tracking information and operations for a given property of this entity.

public virtual PropertyEntry Property(string propertyName)
Public Overridable Function Property(propertyName As String) As PropertyEntry
Parameters
propertyName
System.String System.String

The property to access information and operations for.

Returns

An object that exposes change tracking information and operations for the given property.

Reference(String) Reference(String)

Provides access to change tracking and loading information for a reference (i.e. non-collection) navigation property that associates this entity to another entity.

public virtual ReferenceEntry Reference(string navigationPropertyName)
Public Overridable Function Reference(navigationPropertyName As String) As ReferenceEntry
Parameters
navigationPropertyName
System.String System.String

The name of the navigation property.

Returns

An object that exposes change tracking information and operations for the given navigation property.

Reload() Reload()

Reloads the entity from the database overwriting any property values with values from the database.

The entity will be in the Unchanged state after calling this method, unless the entity does not exist in the database, in which case the entity will be Detached. Finally, calling Reload on an Added entity that does not exist in the database is a no-op. Note, however, that an Added entity may not yet have had its permanent key value created.

public virtual void Reload()
Public Overridable Sub Reload

ReloadAsync(CancellationToken) ReloadAsync(CancellationToken)

Reloads the entity from the database overwriting any property values with values from the database.

The entity will be in the Unchanged state after calling this method, unless the entity does not exist in the database, in which case the entity will be Detached. Finally, calling Reload on an Added entity that does not exist in the database is a no-op. Note, however, that an Added entity may not yet have had its permanent key value created.

public virtual Task ReloadAsync(CancellationToken cancellationToken = null)
Public Overridable Function ReloadAsync(cancellationToken As CancellationToken = Nothing) As Task
Parameters
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns
System.Threading.Tasks.Task System.Threading.Tasks.Task

A task that represents the asynchronous operation.

Explicit Interface Implementations

IInfrastructure.Instance Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure.Instance

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

InternalEntityEntry IInfrastructure<InternalEntityEntry>.Instance { get; }
ReadOnly WriteOnly Property Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry>.Instance As InternalEntityEntry Implements IInfrastructure(Of InternalEntityEntry).Instance
Returns