Interface IDataTypeService
Defines the DataType Service, which is an easy access to operations involving IDataType
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IDataTypeService : IService
Methods
View SourceCopy(IDataType, int)
Copies a IDataType to a given container.
Declaration
[Obsolete("Please use CopyAsync instead. Scheduled for removal in Umbraco 18.")]
Attempt<OperationResult<MoveOperationStatusType, IDataType>?> Copy(IDataType copying, int containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | copying | The data type to copy. |
| int | containerId | The ID of the target container. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<MoveOperationStatusType, IDataType>> | An operation result containing the copied data type. |
Copy(IDataType, int, int)
Copies a IDataType to a given container.
Declaration
[Obsolete("Please use CopyAsync instead. Scheduled for removal in Umbraco 18.")]
Attempt<OperationResult<MoveOperationStatusType, IDataType>?> Copy(IDataType copying, int containerId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | copying | The data type to copy. |
| int | containerId | The ID of the target container. |
| int | userId | The ID of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<MoveOperationStatusType, IDataType>> | An operation result containing the copied data type. |
CopyAsync(IDataType, Guid?, Guid)
Copies a IDataType to a given container
Declaration
Task<Attempt<IDataType, DataTypeOperationStatus>> CopyAsync(IDataType toCopy, Guid? containerKey, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | toCopy | The data type that will be copied |
| Guid? | containerKey | The container key where the data type will be copied to. |
| Guid | userKey | The user that did the Copy action |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IDataType, DataTypeOperationStatus>> | An attempt result with the copied data type and operation status. |
CreateAsync(IDataType, Guid)
Creates a new IDataType
Declaration
Task<Attempt<IDataType, DataTypeOperationStatus>> CreateAsync(IDataType dataType, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | dataType | IDataType to create |
| Guid | userKey | Key of the user issuing the creation |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IDataType, DataTypeOperationStatus>> |
CreateContainer(int, Guid, string, int)
Creates a container for organizing data types.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
Attempt<OperationResult<OperationResultType, EntityContainer>?> CreateContainer(int parentId, Guid key, string name, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | The parent container ID, or -1 for root. |
| Guid | key | The unique key for the new container. |
| string | name | The name of the container. |
| int | userId | The ID of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, EntityContainer>> | An operation result containing the created container. |
Delete(IDataType, int)
Deletes an IDataType
Declaration
[Obsolete("Please use DeleteAsync. Scheduled for removal in Umbraco 18.")]
void Delete(IDataType dataType, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | dataType | IDataType to delete |
| int | userId | Id of the user issuing the deletion |
Remarks
Please note that deleting a IDataType will remove all the IPropertyType data that references this IDataType.
DeleteAsync(Guid, Guid)
Deletes an IDataType
Declaration
Task<Attempt<IDataType?, DataTypeOperationStatus>> DeleteAsync(Guid id, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | id | The guid Id of the IDataType to delete |
| Guid | userKey | Key of the user issuing the deletion |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IDataType, DataTypeOperationStatus>> |
Remarks
Please note that deleting a IDataType will remove all the IPropertyType data that references this IDataType.
DeleteContainer(int, int)
Deletes a container.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
Attempt<OperationResult?> DeleteContainer(int containerId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | containerId | The ID of the container to delete. |
| int | userId | The ID of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | An operation result indicating success or failure. |
FilterAsync(string?, string?, string?, int, int)
Gets multiple IDataType objects by their unique keys.
Declaration
Task<PagedModel<IDataType>> FilterAsync(string? name = null, string? editorUiAlias = null, string? editorAlias = null, int skip = 0, int take = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name to filter by. |
| string | editorUiAlias | Editor ui alias to filter by. |
| string | editorAlias | Editor alias to filter by. |
| int | skip | Number of items to skip. |
| int | take | Number of items to take. |
Returns
| Type | Description |
|---|---|
| Task<PagedModel<IDataType>> | An attempt with the requested data types. |
GetAll(params int[])
Gets all IDataType objects or those with the ids passed in
Declaration
[Obsolete("Please use GetAllAsync. Scheduled for removal in Umbraco 18.")]
IEnumerable<IDataType> GetAll(params int[] ids)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | ids | Optional array of Ids |
Returns
| Type | Description |
|---|---|
| IEnumerable<IDataType> | An enumerable list of IDataType objects |
GetAllAsync(params Guid[])
Gets multiple IDataType objects by their unique keys.
Declaration
Task<IEnumerable<IDataType>> GetAllAsync(params Guid[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid[] | keys | The keys to get datatypes by. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IDataType>> | An attempt with the requested data types. |
GetAsync(Guid)
Gets an IDataType by its unique guid Id
Declaration
Task<IDataType?> GetAsync(Guid id)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | id | Unique guid Id of the DataType |
Returns
| Type | Description |
|---|---|
| Task<IDataType> |
GetAsync(string)
Gets an IDataType by its Name
Declaration
Task<IDataType?> GetAsync(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the IDataType |
Returns
| Type | Description |
|---|---|
| Task<IDataType> |
GetByEditorAlias(string)
Gets a IDataType by its control Id
Declaration
[Obsolete("Please use GetByEditorAliasAsync. Scheduled for removal in Umbraco 18.")]
IEnumerable<IDataType> GetByEditorAlias(string propertyEditorAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyEditorAlias | Alias of the property editor |
Returns
| Type | Description |
|---|---|
| IEnumerable<IDataType> | Collection of IDataType objects with a matching control id |
GetByEditorAliasAsync(string)
Gets all IDataType for a given property editor.
Declaration
Task<IEnumerable<IDataType>> GetByEditorAliasAsync(string propertyEditorAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyEditorAlias | Alias of the property editor. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IDataType>> | Collection of IDataType configured for the property editor. |
GetByEditorAliasAsync(string[])
Gets all IDataType for a set of property editors.
Declaration
Task<IEnumerable<IDataType>> GetByEditorAliasAsync(string[] propertyEditorAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | propertyEditorAlias | Aliases of the property editors. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IDataType>> | Collection of IDataType configured for the property editors. |
GetByEditorUiAlias(string)
Gets all IDataType for a given editor UI alias.
Declaration
Task<IEnumerable<IDataType>> GetByEditorUiAlias(string editorUiAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | editorUiAlias | The UI Alias to query by. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<IDataType>> | Collection of IDataType which has the UI alias. |
GetContainer(Guid)
Gets a container by its unique key.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
EntityContainer? GetContainer(Guid containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | containerId | The container unique key. |
Returns
| Type | Description |
|---|---|
| EntityContainer | The container, or null if not found. |
GetContainer(int)
Gets a container by its ID.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
EntityContainer? GetContainer(int containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | containerId | The container ID. |
Returns
| Type | Description |
|---|---|
| EntityContainer | The container, or null if not found. |
GetContainers(int[])
Gets containers by their IDs.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
IEnumerable<EntityContainer> GetContainers(int[] containerIds)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | containerIds | The container IDs. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of containers. |
GetContainers(string, int)
Gets containers by name and level.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
IEnumerable<EntityContainer> GetContainers(string folderName, int level)
Parameters
| Type | Name | Description |
|---|---|---|
| string | folderName | The container name. |
| int | level | The container level. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of matching containers. |
GetContainers(IDataType)
Gets all ancestor containers for a data type.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
IEnumerable<EntityContainer> GetContainers(IDataType dataType)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | dataType | The data type. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of ancestor containers. |
GetDataType(int)
Gets a IDataType by its Id
Declaration
[Obsolete("Please use GetAsync. Scheduled for removal in Umbraco 18.")]
IDataType? GetDataType(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the IDataType |
Returns
| Type | Description |
|---|---|
| IDataType |
GetDataType(string)
Gets a IDataType by its Name
Declaration
[Obsolete("Please use GetAsync. Scheduled for removal in Umbraco 18.")]
IDataType? GetDataType(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the IDataType |
Returns
| Type | Description |
|---|---|
| IDataType |
GetPagedRelationsAsync(Guid, int, int)
Gets a paged result of items which are in relation with the current data type.
Declaration
Task<PagedModel<RelationItemModel>> GetPagedRelationsAsync(Guid key, int skip, int take)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The identifier of the data type to retrieve relations for. |
| int | skip | The amount of items to skip |
| int | take | The amount of items to take. |
Returns
| Type | Description |
|---|---|
| Task<PagedModel<RelationItemModel>> | A paged result of RelationItemModel objects. |
Remarks
Note that the model and method signature here aligns with with how we handle retrieval of concrete Umbraco relations based on documents, media and members in ITrackedReferencesService. The intention is that we align data type relations with these so they can be handled polymorphically at the management API and backoffice UI level.
Move(IDataType, int)
Moves a IDataType to a given container.
Declaration
[Obsolete("Please use MoveAsync instead. Scheduled for removal in Umbraco 18.")]
Attempt<OperationResult<MoveOperationStatusType>?> Move(IDataType toMove, int parentId)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | toMove | The data type that will be moved. |
| int | parentId | The ID of the parent container to move to. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<MoveOperationStatusType>> | An operation result indicating the move status. |
MoveAsync(IDataType, Guid?, Guid)
Moves a IDataType to a given container
Declaration
Task<Attempt<IDataType, DataTypeOperationStatus>> MoveAsync(IDataType toMove, Guid? containerKey, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | toMove | The data type that will be moved |
| Guid? | containerKey | The container key where the data type will be moved to. |
| Guid | userKey | The user that did the Move action |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IDataType, DataTypeOperationStatus>> | An attempt result with the moved data type and operation status. |
RenameContainer(int, string, int)
Renames a container.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
Attempt<OperationResult<OperationResultType, EntityContainer>?> RenameContainer(int id, string name, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The ID of the container to rename. |
| string | name | The new name for the container. |
| int | userId | The ID of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, EntityContainer>> | An operation result containing the renamed container. |
Save(IEnumerable<IDataType>, int)
Saves a collection of IDataType
Declaration
[Obsolete("Please use CreateAsync or UpdateAsync. Scheduled for removal in Umbraco 18.")]
void Save(IEnumerable<IDataType> dataTypeDefinitions, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IDataType> | dataTypeDefinitions | IDataType to save |
| int | userId | Id of the user issuing the save |
Save(IDataType, int)
Saves an IDataType
Declaration
[Obsolete("Please use CreateAsync or UpdateAsync. Scheduled for removal in Umbraco 18.")]
void Save(IDataType dataType, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | dataType | IDataType to save |
| int | userId | Id of the user issuing the save |
SaveContainer(EntityContainer, int)
Saves a container.
Declaration
[Obsolete("Please use IDataTypeContainerService for all data type container operations. Scheduled for removal in Umbraco 18.")]
Attempt<OperationResult?> SaveContainer(EntityContainer container, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityContainer | container | The container to save. |
| int | userId | The ID of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | An operation result indicating success or failure. |
UpdateAsync(IDataType, Guid)
Updates an existing IDataType
Declaration
Task<Attempt<IDataType, DataTypeOperationStatus>> UpdateAsync(IDataType dataType, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | dataType | IDataType to update |
| Guid | userKey | Key of the user issuing the update |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IDataType, DataTypeOperationStatus>> |
ValidateConfigurationData(IDataType)
Performs validation for the configuration data of a given data type.
Declaration
IEnumerable<ValidationResult> ValidateConfigurationData(IDataType dataType)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataType | dataType | The data type whose configuration to validate. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ValidationResult> | One or more System.ComponentModel.DataAnnotations.ValidationResult if the configuration data is invalid, an empty collection otherwise. |