create Entity
See createEntity_(EntityValue, HttpHeaders?, RequestOptions?).
Parameters
Entity parameter.
See createEntity_(EntityValue, HttpHeaders?, RequestOptions?).
Parameters
Entity parameter.
Headers parameter.
Create an entity in the target system. Automatically calls {@link com.sap.cloud.mobile.kotlin.odata.csdl.CsdlDocument#resolveEntity(com.sap.cloud.mobile.kotlin.odata.EntityValue) CsdlDocument.resolveEntity} to ensure that {@link com.sap.cloud.mobile.kotlin.odata.EntityValue#entitySet EntityValue.entitySet} is available.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.EntityValue#ofType(com.sap.cloud.mobile.kotlin.odata.EntityType, com.sap.cloud.mobile.kotlin.odata.core.SparseIndexMap?) EntityValue.ofType}, {@link com.sap.cloud.mobile.kotlin.odata.EntityValue#inSet(com.sap.cloud.mobile.kotlin.odata.EntitySet) EntityValue.inSet}, {@link com.sap.cloud.mobile.kotlin.odata.DataServiceAsync#createRelatedEntity_(com.sap.cloud.mobile.kotlin.odata.EntityValue, com.sap.cloud.mobile.kotlin.odata.EntityValue, com.sap.cloud.mobile.kotlin.odata.Property, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders?, com.sap.cloud.mobile.kotlin.odata.RequestOptions?) DataServiceAsync.createRelatedEntity}, Create Related Entities When Creating an Entity.
- Example using proxy classes:
open fun createEntityExample(): kotlin.Unit { val service = this.service; val customer = Customer(); customer.companyName = "Enterprise Inc."; customer.contactName = "Jean-Luc Picard"; service.createEntity(customer); }
- Example using proxy classes:
open fun deepCreateExample(): kotlin.Unit { val service = this.service; val customer = Customer(); customer.companyName = "Enterprise Inc."; customer.contactName = "LeVar Burton"; val order1 = Order(); val order2 = Order(); customer.bindEntity(order1, Customer.orders); customer.bindEntity(order2, Customer.orders); service.createEntity(customer.withDeepCreate()); }
- Example using proxy classes:
open fun createInSetExample(): kotlin.Unit { val service = this.service; val customer = Customer(); customer.companyName = "Voyager Inc."; customer.contactName = "Kathryn Janeway"; service.createEntity(customer.inSet(NorthwindService.customers)); }
- Example using dynamic API:
open fun createEntityExample(): kotlin.Unit { val service = this.service; val customersEntitySet = service.getEntitySet("Customers"); val customerEntityType = customersEntitySet.entityType; val companyNameProperty = customerEntityType.getProperty("CompanyName"); val contactNameProperty = customerEntityType.getProperty("ContactName"); val customer = EntityValue.ofType(customerEntityType); companyNameProperty.setString(customer, "Enterprise Inc."); contactNameProperty.setString(customer, "Jean-Luc Picard"); service.createEntity(customer); }
Parameters
Entity to be created.
(nullable) Optional request-specific headers.
(nullable) Optional request-specific options.