Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

Class EntityReference

A light-weight reference to an IEntity primarily used to save references to other entities

Inheritance
System.Object
EntityReference
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Data.Entity
Assembly: EPiServer.Data.dll
Version: 11.20.7
Syntax
public class EntityReference

Constructors

EntityReference()

Declaration
protected EntityReference()

EntityReference(Type, Int32)

Initializes a new instance of this class.

Declaration
public EntityReference(Type type, int id)
Parameters
Type Name Description
System.Type type

The type of the entity

System.Int32 id

The ID of the entity

Properties

Empty

The empty EntityReference

Declaration
public static EntityReference Empty { get; }
Property Value
Type Description
EntityReference

ID

The ID of the entity

Declaration
public int ID { get; protected set; }
Property Value
Type Description
System.Int32

Type

Type type of the entity

Declaration
public Type Type { get; }
Property Value
Type Description
System.Type

Methods

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
Overrides
System.Object.Equals(System.Object)

GetEntityType(Type)

Gets the Type designated as EntityType for the given Type (taking EntityTypeOverrideAttribute into account)

Declaration
public static Type GetEntityType(Type originalType)
Parameters
Type Name Description
System.Type originalType

The Type to inspect

Returns
Type Description
System.Type

Returns the Type designated as EntityType. If no EntityTypeOverrideAttribute could be found in the inheritance chain, it returns the type supplied in originalType.

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.Object.GetHashCode()

ToEntityReference(IEntity)

Gets an EntityReference to an IEntity

Declaration
public static EntityReference ToEntityReference(IEntity entity)
Parameters
Type Name Description
IEntity entity

The entity to which you want to get a reference

Returns
Type Description
EntityReference

An EntityReference to entity, or Empty if entity is null

Operators

Equality(EntityReference, EntityReference)

Declaration
public static bool operator ==(EntityReference entity1, EntityReference entity2)
Parameters
Type Name Description
EntityReference entity1
EntityReference entity2
Returns
Type Description
System.Boolean

Inequality(EntityReference, EntityReference)

Declaration
public static bool operator !=(EntityReference entity1, EntityReference entity2)
Parameters
Type Name Description
EntityReference entity1
EntityReference entity2
Returns
Type Description
System.Boolean

Extension Methods