且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在收集OData的名单

更新时间:2023-12-03 13:15:16

一我能想到的办法是:
当你获得这个页面的响应:的 http://services.odata.org/V4/Northwind/Northwind.svc/ 响应是一个Atom feed,你可以处理它作为一个Atom feed或XML,基本上加载XML和阅读的元素到你的代码,并利用它们从那里。


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"]); 
 } 
} 

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.