Skip to main content

$clean

Functionality

The $clean endpoint creates a new entity set from an existing entity set but without its deleted entities, if any.

Definition

$clean creates a new entity set containing the same entities as entitySetID but without references to deleted entities (if any).

By default, when an entity is deleted, its reference(s) in existing entity set(s) become undefined but are not removed. They are also still included in the "count" property of the entity set. Calling $clean on the entity set returns a new, up-to-date entity set without undefined entity references.

Syntax

To use the $clean endpoint, append it to your GET request in the following manner:

GET /rest/{{dataClass}}/$entityset/{{entitySetID}}?$clean={{boolean}}
tip

$clean is usually followed by $method=entityset to create the new entity set on the server:

/Employee/$entityset/9718A30BF61343C796345F3BE5B01CE7?$clean=true&$method=entityset

Example

  1. We create an entity set:
GET /rest/Speciality?$filter="ID<=3"&$method=entityset

Three entities are received and we get the entity set DF6903FB5879404A9A818884CFC6F62A

{
"__ENTITYSET": "/rest/Speciality/$entityset/DF6903FB5879404A9A818884CFC6F62A",
"__DATACLASS": "Speciality",
"__entityModel": "Speciality",
"__GlobalStamp": 0,
"__COUNT": 3,
"__FIRST": 0,
"__ENTITIES": [
{
"__KEY": "1",
"__TIMESTAMP": "2024-04-23T10:42:28.097Z",
"__STAMP": 131,
"ID": 1,
"name": "Surgery",
"infos": {
"__deferred": {
"uri": "/rest/Speciality[1]/infos?$expand=infos"
}
}
},
{
"__KEY": "2",
"__TIMESTAMP": "2024-04-23T10:42:28.097Z",
"__STAMP": 131,
"ID": 2,
"name": "Otolaryngology",
"infos": {
"__deferred": {
"uri": "/rest/Speciality[2]/infos?$expand=infos"
}
}
},
{
"__KEY": "3",
"__TIMESTAMP": "2024-04-23T10:42:28.097Z",
"__STAMP": 131,
"ID": 3,
"name": "Dentist",
"infos": {
"__deferred": {
"uri": "/rest/Speciality[3]/infos?$expand=infos"
}
}
},
],
"__SENT": 3
}
  1. We delete the entity with KEY=2 (see how to delete an entity), then this request is sent:

GET /rest/Speciality/$entityset/DF6903FB5879404A9A818884CFC6F62A

The entity set is returned and still contains 3 entities. There is an undefined entity for the deleted entity (with stamp = 0):

{
"__DATACLASS": "Speciality",
"__entityModel": "Speciality",
"__GlobalStamp": 0,
"__COUNT": 3,
"__FIRST": 0,
"__ENTITIES": [
{
"__KEY": "1",
"__TIMESTAMP": "2024-04-23T10:42:28.097Z",
"__STAMP": 131,
"ID": 1,
"name": "Surgery",
"infos": {
"__deferred": {
"uri": "/rest/Speciality[1]/infos?$expand=infos"
}
}
},
{
"__STAMP": 0
},
{
"__KEY": "3",
"__TIMESTAMP": "2024-04-23T10:42:28.097Z",
"__STAMP": 131,
"ID": 3,
"name": "Dentist",
"infos": {
"__deferred": {
"uri": "/rest/Speciality[3]/infos?$expand=infos"
}
}
},
],
"__SENT": 3
}
  1. If this request is sent:

GET /rest/Speciality/$entityset/DF6903FB5879404A9A818884CFC6F62A?$clean=true&$method=entityset

We clean the entity set DF6903FB5879404A9A818884CFC6F62A and receive a new entity set (entity set D7BFBC49375B4FE5A94CDD17AA535F73) that does not contain the dropped entity:

{
"__ENTITYSET": "/rest/Speciality/$entityset/D7BFBC49375B4FE5A94CDD17AA535F73",
"__DATACLASS": "Speciality",
"__entityModel": "Speciality",
"__GlobalStamp": 0,
"__COUNT": 2,
"__FIRST": 0,
"__ENTITIES": [
{
"__KEY": "1",
"__TIMESTAMP": "2024-04-23T10:42:28.097Z",
"__STAMP": 131,
"ID": 1,
"name": "Surgery",
"infos": {
"__deferred": {
"uri": "/rest/Speciality[1]/infos?$expand=infos"
}
}
},
{
"__KEY": "3",
"__TIMESTAMP": "2024-04-23T10:42:28.097Z",
"__STAMP": 131,
"ID": 3,
"name": "Dentist",
"infos": {
"__deferred": {
"uri": "/rest/Speciality[3]/infos?$expand=infos"
}
}
}
],
"__SENT": 2
}