bindEntity

open fun bindEntity(entity: EntityValue, to: Property)

Bind an entity to 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 bindEntityExample(): kotlin.Unit
{
    val service = this.service;
    val categoryQuery = DataQuery().top(1).expand(Category.products);
    val category = service.getCategory(categoryQuery);
    val productQuery = DataQuery().top(1);
    val product = service.getProduct(productQuery);
    category.bindEntity(product, Category.products);
    service.updateEntity(category);
}
Example using dynamic API:
open fun bindEntityExample(): kotlin.Unit
{
    val service = this.service;
    val categoriesEntitySet = service.getEntitySet("Categories");
    val productsEntitySet = service.getEntitySet("Products");
    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 productQuery = DataQuery().from(productsEntitySet).top(1);
    val product = service.executeQuery(productQuery).getRequiredEntity();
    category.bindEntity(product, productsProperty);
    service.updateEntity(category);
}

Parameters

entity

Entity to be bound.

to

Property the entity will be bound to.