unbindEntity

open fun unbindEntity(entity: EntityValue?, from: Property)

See unbindEntity(EntityValue?, Property, Boolean).

Parameters

entity

Entity parameter.

from

From parameter.


open fun unbindEntity(entity: EntityValue?, from: Property, deleted: Boolean)

Unbind an entity from a property of the current entity. This can be used before DataService.createEntity or DataService.updateEntity to create or update the bindings of navigation properties.

Example using proxy classes:
open fun unbindEntityExample(): kotlin.Unit
{
    val service = this.service;
    val categoryQuery = DataQuery().top(1).expand(Category.products);
    val category = service.getCategory(categoryQuery);
    val products = category.products;
    if (products.size != 0)
    {
        val product = products.get(0);
        category.unbindEntity(product, Category.products);
    }
    service.updateEntity(category);
}
Example using dynamic API:
open fun unbindEntityExample(): kotlin.Unit
{
    val service = this.service;
    val categoriesEntitySet = service.getEntitySet("Categories");
    val categoryEntityType = categoriesEntitySet.entityType;
    val productsProperty = categoryEntityType.getProperty("Products");
    val categoryQuery = DataQuery().from(categoriesEntitySet).top(1)
        .expand(productsProperty);
    val category = service.executeQuery(categoryQuery).getRequiredEntity();
    val products = productsProperty.getEntityList(category);
    if (products.length != 0)
    {
        val product = products.first();
        category.unbindEntity(product, productsProperty);
    }
    service.updateEntity(category);
}

Parameters

entity

(nullable) Entity to be unbound. Can be null for unbinding an entity from a single-valued navigation property.

from

Property the entity will be unbound from.

deleted

Indicates that as well as being unbound from the current entity, the previously bound entity should be deleted.