load Property
See loadProperty_(Property, EntityValue, DataQuery?, HttpHeaders?, RequestOptions?).
Parameters
Property parameter.
Into parameter.
See loadProperty_(Property, EntityValue, DataQuery?, HttpHeaders?, RequestOptions?).
Parameters
Property parameter.
Into parameter.
Query parameter.
See loadProperty_(Property, EntityValue, DataQuery?, HttpHeaders?, RequestOptions?).
Parameters
Property parameter.
Into parameter.
Query parameter.
Headers parameter.
Load the value of a property into an existing entity. This can be applied to both structural and navigation properties.
- Example using proxy classes:
open fun loadPropertyExample(): kotlin.Unit { val service = this.service; val query = DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .filter(Customer.customerID.equal("ALFKI") .or(Customer.customerID.equal("ANATR"))); val responseHeaders = com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders(); val requestOptions = RequestOptions(); requestOptions.captureResponseHeaders = responseHeaders; val customers = service.getCustomers(query, null, requestOptions); var countOrders = 0; L491@ for (customer in customers) { this.showCustomer(customer); service.loadProperty(Customer.orders, customer); val orders = customer.orders; L496@ for (order in orders) { val orderID = order.orderID; Example.show(" Order ", Example.formatInt(orderID)); countOrders++; } } Assert.isTrue(countOrders > 0, "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.NorthwindProxyClient.xs:503:9"); Assert.isTrue(this.checkContentTypeJson(responseHeaders), "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.NorthwindProxyClient.xs:504:9"); }
- Example using proxy classes (in request batch):
open fun loadPropertyInBatchExample(): kotlin.Unit { val service = this.service; val query = DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .filter(Customer.customerID.equal("ALFKI") .or(Customer.customerID.equal("ANATR"))); val customers = service.getCustomers(query); val customer1 = customers[0]; val customer2 = customers[1]; val query1 = DataQuery().load(customer1, Customer.orders); val query2 = DataQuery().load(customer2, Customer.orders); val secondResponseHeaders = com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders(); val secondRequestOptions = RequestOptions(); secondRequestOptions.captureResponseHeaders = secondResponseHeaders; val batch = RequestBatch(); batch.addQuery(query1); batch.addQuery(query2, null, secondRequestOptions); service.processBatch(batch); val result1 = batch.getQueryResult(query1); val result2 = batch.getQueryResult(query2); val orders1 = Order.list(result1.getEntityList()); val orders2 = Order.list(result2.getEntityList()); Assert.isTrue(orders1.size != 0, "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.NorthwindProxyClient.xs:530:9"); Assert.isTrue(orders2.size != 0, "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.NorthwindProxyClient.xs:531:9"); customer1.orders = orders1; customer2.orders = orders2; Assert.isTrue(this.checkContentTypeJson(secondResponseHeaders), "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.NorthwindProxyClient.xs:534:9"); }
- Example using dynamic API:
open fun loadPropertyExample(): kotlin.Unit { val service = this.service; val customersEntitySet = service.getEntitySet("Customers"); val customerEntityType = customersEntitySet.entityType; val customerIDProperty = customerEntityType.getProperty("CustomerID"); val companyNameProperty = customerEntityType.getProperty("CompanyName"); val contactNameProperty = customerEntityType.getProperty("ContactName"); val ordersProperty = customerEntityType.getProperty("Orders"); val orderIDProperty = ordersProperty.itemEntityType.getProperty("OrderID"); val query = DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet) .filter(customerIDProperty.equal("ALFKI") .or(customerIDProperty.equal("ANATR"))); val customers = service.executeQuery(query).getEntityList(); var countOrders = 0; L542@ for (customer in customers) { this.showCustomer(customer); service.loadProperty(ordersProperty, customer); val orders = ordersProperty.getEntityList(customer); L547@ for (order in orders) { val orderID = orderIDProperty.getInt(order); Example.show(" Order ", Example.formatInt(orderID)); countOrders++; } } Assert.isTrue(countOrders > 0, "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.NorthwindClient.xs:554:9"); }
- Example using dynamic API (in request batch):
open fun loadPropertyInBatchExample(): kotlin.Unit { val service = this.service; val customersEntitySet = service.getEntitySet("Customers"); val customerEntityType = customersEntitySet.entityType; val customerIDProperty = customerEntityType.getProperty("CustomerID"); val companyNameProperty = customerEntityType.getProperty("CompanyName"); val contactNameProperty = customerEntityType.getProperty("ContactName"); val ordersProperty = customerEntityType.getProperty("Orders"); val query = DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet) .filter(customerIDProperty.equal("ALFKI") .or(customerIDProperty.equal("ANATR"))); val customers = service.executeQuery(query).getEntityList(); val customer1 = customers[0]; val customer2 = customers[1]; val query1 = DataQuery().load(customer1, ordersProperty); val query2 = DataQuery().load(customer2, ordersProperty); val batch = RequestBatch(); batch.addQuery(query1); batch.addQuery(query2); service.processBatch(batch); val result1 = batch.getQueryResult(query1); val result2 = batch.getQueryResult(query2); val orders1 = result1.getEntityList(); val orders2 = result2.getEntityList(); Assert.isTrue(orders1.length != 0, "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.NorthwindClient.xs:584:9"); Assert.isTrue(orders2.length != 0, "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.NorthwindClient.xs:585:9"); ordersProperty.setEntityList(customer1, orders1); ordersProperty.setEntityList(customer2, orders2); }
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataQuery#load(com.sap.cloud.mobile.kotlin.odata.EntityValue, com.sap.cloud.mobile.kotlin.odata.PropertyPath?) DataQuery.load}.
Parameters
Property to load.
Existing entity.
(nullable) Optional data query, to specify loading criteria (especially for navigation properties).
(nullable) Optional request-specific headers.
(nullable) Optional request-specific options.