Client-side call to a WCF DataService [WebGet] function

entity-framework odata stored-procedures wcf


I want to invoke a stored procedure in an EF4 model from the client. The server code appears as follows:

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>();

This works as anticipated when accessed with Internet Explorer at the URL "http://localhost:12345/MyService.svc/GetSalesReport?reportType=1&yr=2009&m=4&d=2".

I created a reference to the service (http://localhost:12345/MyService.svc) in my client application, however no matter what I do, the method "GetSalesReport" does not appear in the object browser. (The object browser does display typical EF entities.)

Therefore, I want to know how to invoke this method from the Client.

And is there a client-specific distinction in how to call this function? (I want to call this function from a Windows Phone 7 Silverlight App, but right now I am testing using a WPF test client).

1/11/2011 5:19:34 PM

Popular Answer

Actually, it seems that CodeGen has not been implemented by the ADO.NET DataTeam for invoking a ServiceMethod from the client.

Writing the following code at the client is the solution to my issue.

        // 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);

Gil Fink, who authored this blog article, deserves to be thanked.

1/12/2011 9:46:06 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow