List of Collection Names in oData

ε祈祈猫儿з 提交于 2019-12-23 01:14:09

问题


I am little of confused how to get list of collection names from the following odata service http://services.odata.org/V4/Northwind/Northwind.svc/

I just want to get a list of all of the available collection names in the service And then I'd like to let the user choose which collection to view information for, and subsequently show items in that collection

For example, the following line accessing to Customers collection.

var customers = client.For("Customers").FindEntriesAsync(); 

I could able to access inside of each collection as follows.

static void Main(string[] args) 
{ 

 var client = new ODataClient("services.odata.org/Northwind/Northwind.svc/");        

 var customers = client.For("Customers").FindEntriesAsync(); 

 foreach (var customer in customers) {   

     Console.WriteLine(customer["CustomerID"]); 
 } 
} 

回答1:


One way that I can think of is: When you get the response of this page: http://services.odata.org/V4/Northwind/Northwind.svc/ the response is an Atom feed and you can deal with it as an ATOM Feed or XML and basically load the XML and read the elements into your code and use them from there.



来源:https://stackoverflow.com/questions/29996406/list-of-collection-names-in-odata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!