Interface IEntityResolver
Defines a service that can resolve an EntityReference to the unique identity of the referenced IEntity and vice versa.
Namespace: EPiServer.Data.Entity
Assembly: EPiServer.Data.dll
Version: 11.20.7Syntax
public interface IEntityResolver
Examples
Load an IEntity by unique id
public IEntity GetEntityByGuid(Guid guid)
{
IEntityResolver resolver = ServiceLocator.Current.GetInstance<IEntityResolver>();
EntityReference reference = resolver.GetEntityReference(guid);
if(reference!=EntityReference.Empty)
{
IEntityProvider provider = EntityProviderHandler.Instance.GetEntityProvider(reference.Type);
return provider.GetEntityInstance(reference.Type,reference.ID);
}
return null;
}
Methods
GetEntityReference(Guid)
Gets an EntityReference to the IEntity with the specified unique identity.
Declaration
EntityReference GetEntityReference(Guid uniqueId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | uniqueId | The unique identity of the entity. |
Returns
Type | Description |
---|---|
EntityReference | The EntityReference that referes to the IEntity with the given unique identity, or Empty if not found. |
GetEntityUniqueID(EntityReference)
Gets the unique identity of the IEntity that is referenced by the specified EntityReference.
Declaration
Guid GetEntityUniqueID(EntityReference entityReference)
Parameters
Type | Name | Description |
---|---|---|
EntityReference | entityReference | A reference to the entity. |
Returns
Type | Description |
---|---|
System.Guid | The unique identity of the IEntity that the given EntityReference refers to, or System.Guid.Empty if not found. |