从客户端调用WCF DataService [WebGet]函数

Ron*_*nny 2 wcf stored-procedures entity-framework odata

我有一个EF4模型,其中包含我想从客户端调用的存储过程.服务器代码如下所示:

[WebGet]        
public IQueryable<SalesData> GetSalesReport(int reportType, int yr, int m, int d)
{
    DateTime dt = new DateTime(yr, m, d);
    return this.CurrentDataSource.RP_SalesReport(reportType, dt, dt).AsQueryable<SalesData>();
}
Run Code Online (Sandbox Code Playgroud)

当使用URL"http:// localhost:12345/MyService.svc/GetSalesReport?reportType = 1&yr = 2009&m = 4&d = 2"使用IE调用它时,它按预期工作.

在我的客户端应用程序中,我添加了对服务的引用(http:// localhost:12345/MyService.svc),并且在我尝试过之后,函数"GetSalesReport"没有出现在对象浏览器中.(正常EF实体确实显示在对象浏览器中)

所以我的问题是:如何从客户端调用此功能?

如何根据客户端调用此函数有什么不同(我想从Windows Phone 7 Silverlight应用程序调用此函数,但现在我正在使用WPF测试客户端进行测试).

Ron*_*nny 5

实际上,看起来ADO.NET DataTeam还没有实现CodeGen来从客户端调用ServiceMethod.

所以解决我的问题是在客户端编写这段代码:

        // execute the service operation
        Uri u = new Uri(string.Format("{0}/GetSalesReport?reportType={1}&yr={2}&m={3}&d={4}", 
                      context.BaseUri, 1, 2009, 4, 2),UriKind.RelativeOrAbsolute);

        var datas = context.Execute<SalesData>(u);
Run Code Online (Sandbox Code Playgroud)

由于吉尔芬克说写这篇博客文章:http://blogs.microsoft.co.il/blogs/gilf/archive/2008/11/14/consuming-data-services-service-operations.aspx