【发布时间】:2012-03-24 03:50:13
【问题描述】:
我正在通过 C# ASP.NET 应用程序连接到 ODATA 服务,该应用程序具有以下服务操作:
GetItems(int? itemID, double? price)
我可以在浏览器中毫无问题地使用它,例如
http://api.mycompany.com/companycatalogue/GetItems?itemID=4
我了解如何使用 LINQ to Entities 来使用 ODATA 服务,但找不到关于如何在 C# 中使用上述服务操作的适当解释。我在我的 Visual Studio 解决方案中对服务进行了 Web 引用。
到目前为止,我有这样的东西用于我通常的数据消费:
using CompanyCatalogue; //my web reference
...
protected void Page_Load(object sender, EventArgs e)
{
CompanyCatalogueEntities dataContext = new CompanyCatalogueEntities (new Uri("http://api.mycompany.com/companycatalogue/"));
var result = from i in dataContext.Items select i; //just an example
//this is where I get into problems
var operationResults = CompanyCatalogue.GetItems(6, 20.5); //I just made this up
}
任何指针?
【问题讨论】:
标签: c# asp.net rest odata service-operations