DbEntityEntry Class


DBEntityEntry class is useful in retrieving various information about an entity. You can get an instance of DBEntityEntry of an entity by using Entry method of DBContext.

For Example:
DBEntityEntry employeeEntry = dbcontext.Entry(EmployeeEntity);

DbEntityEntry enables to set Added, Modified or Deleted EntityState to an entity.

For Example:
context.Entry(employee).State = System.Data.Entity.EntityState.Modified;

DBEntityEntry enables to access entity state, current, and original values of the property of the given entity. 

 

Methods

DbEntityEntry Class
Method Description
Cast<TEntity>()    
 Returns a new instance of the generic DbEntityEntry<TEntity> class for the given generic type for  the  tracked entity represented by this object. Note that the type of the tracked entity must be  compatible  with the generic type or an exception will be thrown.
 Collection(String)   
 Gets an object that represents the collection navigation property from this entity to a collection of  related entities.
ComplexProperty(String)
Gets an object that represents a complex property of this entity.
Equals(DbEntityEntry)
Determines whether the specified DbEntityEntry is equal to this instance. Two DbEntityEntry instances  are considered equal if they are both entries for the same entity on the same DbContext.
Equals(Object)
Determines whether the specified Object is equal to this instance. Two DbEntityEntry instances are  considered equal if they are both entries for the same entity on the same DbContext.(Overrides  Object.Equals(Object).)
 Finalize()
 
GetDatabaseValues()
 Queries the database for copies of the values of the tracked entity as they currently exist in the database.   Note that changing the values in the returned dictionary will not update the values in the database. If  the entity is not found in the database then null is returned.
GetDatabaseValuesAsync()
Asynchronously queries the database for copies of the values of the tracked entity as they currently exist in the database.  Note that changing the values in the returned dictionary will not update the values in the database. If the  entity is not found in the database then null is returned.
GetDatabaseValuesAsync  (CancellationToken)
Asynchronously queries the database for copies of the values of the tracked entity as they currently  exist in the database. Note that changing the values in the returned dictionary will not update the values  in the database. If the entity is not found in the database then null is returned.
GetHashCode()
Returns a hash code for this instance.(Overrides Object.GetHashCode().)
GetType()
Gets the Type of the current instance.
 GetValidationResult()
Validates this DbEntityEntry instance and returns validation result.
 Member(String)    
Gets an object that represents a member of the entity. The runtime type of the returned object will vary depending on what kind of member is asked for. The currently supported member types and their return types are: Reference navigation property: DbReferenceEntry. Collection navigation property: DbCollectionEntry. Primitive/scalar property: DbPropertyEntry. Complex property: DbComplexPropertyEntry.
 MemberwiseClone()
 
 Property(String)
Gets an object that represents a scalar or complex property of this entity.
 Reference(String)    
Gets an object that represents the reference (i.e. non-collection) navigation property from this entity to another entity.
 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.
 ReloadAsync()    
Asynchronously 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.
 ReloadAsync(CancellationToken)    
Asynchronously 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.
 ToString()    
 Returns a sting representation of the DbEntityEntry.(Overrides Object.ToString().)

 

Praesent mattis

Pellentesque viverra vulputate enim. Aliquam erat volutpat. Pellentesque tristique ante ut risus. Quisque dictum. Integer nisl risus, sagittis convallis, rutrum id, elementum congue, nibh. Suspendisse dictum porta lectus. Donec placerat odio vel elit.

Read More