查詢所有客戶訂單我有WCF數據服務(從樣本MS Northwidth數據庫),我的Android應用程序從該服務請求數據與代碼:Android的 - 從OData服務
NorthdataService service = new NorthdataService();
Query<Customers> query = service.createCustomersQuery("/Customers");
for (Customers cust : query){
Log.d(log_tag, "Customer Name - " + cust.getCustomerId());
}
我試着查詢客戶訂單:
Log.d(log_tag, "Orders - " + cust.getOrders());
,看到訂單 - 空
我也知道,在訂單數據,我可以得到一個請求:
http://Server:82/northdata.svc/Customers('ALFKI')/Orders
我嘗試查詢:
for (Customers cust : query){
Log.d(log_tag, "Customer Name - " + cust.getCustomerId());
String custName = "/Customers" + "('" + cust.getCustomerId() + "')" + "/Orders";
try{
Query<Customers> cquery1 = service.createCustomersQuery(custName);
for (Customers orders : cquery1){
Log.d(log_tag, "Orders2 - " + orders.toString());
}
}
catch(Exception e){}
}
我看到的結果:
Orders2 - [email protected]
Orders2 - [email protected]
Orders2 - [email protected]
Orders2 - [email protected]
如何從一個客戶的所有訂單ID?
是的我知道如何獲得ALFKI的所有OrdersID? – xck