locked
Calling a IEnumerable Service Operation from the client (i.e. Silverlight) ? RRS feed

  • Question

  • Calling IQueryable custom service operations from client seems straightforward via :

    public DataServiceQuery<Bed> SpecialBeds()
        {
          return this.CreateQuery<Bed>("SpecialBeds");
        }  
    

    However, if my service op is IEnumerable, I am not sure how to call it from client, as it is not a DataServiceQuery to my knowledge.

    p.s. was thinking I had to hand craft a uri on the client, but still unsure how to setup the GET call.

    Any ideas?

    Wednesday, September 22, 2010 8:06 PM

Answers

  • Hi,

    If the service operation returns IEnumerable of entities, then you can use DataServiceContext.Execute<Entity>. If the service operation returns IEnumerable of primitive or complex types, currently the client library doesn't support parsing such responses. So you would have to use HttpWebRequest directly and parse the response yourself (it's XML after all, so it's usually not that hard).

    Thanks,


    Vitek Karas [MSFT]
    • Marked as answer by Rybolt Wednesday, September 22, 2010 8:51 PM
    Wednesday, September 22, 2010 8:37 PM
    Moderator