expand
Add properties (to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#expandItems DataQuery.expandItems}) for expanding from the target entity.
- Example using proxy classes:
open fun expandExample(): 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"))) .expand(Customer.orders).orderBy(Customer.companyName); val customers = service.getCustomers(query); var countOrders = 0; L574@ for (customer in customers) { this.showCustomer(customer); val orders = customer.orders; L578@ 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:585:9"); }
- Example using dynamic API:
open fun expandExample(): 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).expand(ordersProperty) .filter(customerIDProperty.equal("ALFKI").or(customerIDProperty.equal("ANATR"))) .orderBy(companyNameProperty); val customers = service.executeQuery(query).getEntityList(); var countOrders = 0; L646@ for (customer in customers) { this.showCustomer(customer); val orders = ordersProperty.getEntityList(customer); L650@ 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:657:9"); }
Return
This query.
Parameters
items
The items to be expanded.