Interface IEntityResolver
Defines a service that can resolve an Entity
Namespace: EPiServer.Data.Entity
Assembly: EPiServer.Data.dll
Version: 12.0.3Syntax
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 Entity
Declaration
EntityReference GetEntityReference(Guid uniqueId)
Parameters
Type | Name | Description |
---|---|---|
System. |
uniqueId | The unique identity of the entity. |
Returns
Type | Description |
---|---|
Entity |
The Entity |
GetEntityUniqueID(EntityReference)
Gets the unique identity of the IEntity that is referenced by the specified Entity
Declaration
Guid GetEntityUniqueID(EntityReference entityReference)
Parameters
Type | Name | Description |
---|---|---|
Entity |
entityReference | A reference to the entity. |
Returns
Type | Description |
---|---|
System. |
The unique identity of the IEntity that the given Entity |