How to consume stored procedure from data services RRS feed

  • Question

  • I'm able to consume the table, both in the browser and the codes.  But for the stored procedure, I only able to invoke it via browser.  I can't bind the data to the grid like the table.  Is there a way to do it with stored procedure.  I have tried many way but could not success. 

    Here is the simple sample that I tried in order to do for bigger things later if success:

    ****My service:




    class SampleDB : DataService<SampleDBEntities1>




    // This method is called only once to initialize service-wide policies.



    public static void InitializeService(DataServiceConfiguration config)




    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.



    // Examples:



    "*", EntitySetRights.AllRead);



    "*", ServiceOperationRights.All);

    config.DataServiceBehavior.MaxProtocolVersion =









    public List<GetAllEmployers_Result>GetAllEmployers()




    return CurrentDataSource.GetAllEmployers().ToList();





    ***My client code to consume it:





    partial class _Default : System.Web.UI.Page




    protected void Page_Load(object sender, EventArgs e)




    Uri svcURI = new Uri("http://localhost:27664/SampleDB.svc");



    Uri svcURIOperation = new Uri("http://localhost:27664/SampleDB.svc/GetAllEmployers");



    SampleDBEntities1 context = new SampleDBService.SampleDBEntities1(svcURI);



    //var query = context.Execute<GetAllEmployers_Result>(



    // new Uri(String.Format("{0}GetAllEmployeers",



    // context.BaseUri, 0),



    // uriKind.RelativeOrAbsolute));





    IEnumerable<GetAllEmployers_Result> query = context.Execute<GetAllEmployers_Result>(new Uri(http://localhost:27664/SampleDB.svc/GetAllEmployers));



    gvEmployer.DataSource = query.ToList();





    Learning Sharepoint
    Thursday, January 13, 2011 7:13 PM


  • Hi,

    The client library currently doesn't support consuming results of service operations unless the service operation returns a single entity or a list (IEnumerable or IQueryable) of entities. It's not 100% clear from the code above, but I think your service operation returns enumeration of complex types (the GetAllEmployers_Result is a complex type, right?). If that's the case, then this is not currently a supported scenario. You would have to issue that request manually through some HTTP library (WebClient or HttpWebRequest) and parse the response manually (XLinq is probably the easiest).


    Vitek Karas [MSFT]
    Thursday, January 13, 2011 11:53 PM