我有WCF数据服务(来自示例MS Northwidth数据库),我的Android应用程序通过代码请求来自此服务的数据:
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());
并查看订单 - null
我也知道Orders上的数据可以得到一个请求:
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 - northwindmodel.Customers@40b49f68
Orders2 - northwindmodel.Customers@40c1de10
Orders2 - northwindmodel.Customers@40bdaea8
Orders2 - northwindmodel.Customers@40a6d238
如何从一个客户获得所有OrderID?
答案 0 :(得分:0)
URI~ / Customers('ALFKI')/ $ links / Products使用Id ='ALFKI'标识与客户相关的产品集。
答案 1 :(得分:0)
哦,是的!我解决了我的“问题”......解决方案非常简单,需要在FOR构造订单查询中使用。