locked
DataServiceContext CreateQuery method issue : unwanted parenthesis in operation REST url RRS feed

  • Question

  • Hi,

    I have a strange issue while calling an operation of my my WCF Data Service. Client side I make this query :

    var query = context.CreateQuery("MyOperation").AddQueryOption("param1", "value1");

    when I look to the generated url, it looks like this : 

    http://localhost/Service.svc/MyOperation()?param1=value1

    It crashes because of those unwanted parenthesis at the end of the operation name. If I manually remove them and paste the REST url in my browser it works fine.

    So, how can I do to make the CreateQuery generates the good REST url?

     

    Thank you


    • Edited by cabrinha Wednesday, December 7, 2011 2:12 PM
    Wednesday, December 7, 2011 2:12 PM

Answers

  • Hi,

    If the service operation supports additional query options (That is it returns IQueryable) it will allow the () at the end.

    If it doesn't support additional query options, it fails on the ().

    The CreateQuery method on the client is only supported on entity sets and queryable service operations.

    In this case you will have to unfortunately construct the URL manually.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, December 7, 2011 2:33 PM
    Moderator

All replies

  • Just a little thing more : With the Reflection Data provider, it works fine : No parenthisis are added to the end. It seems to fail only with Entity Framework Data Provider.

     

    Thank you

    Wednesday, December 7, 2011 2:21 PM
  • Hi,

    If the service operation supports additional query options (That is it returns IQueryable) it will allow the () at the end.

    If it doesn't support additional query options, it fails on the ().

    The CreateQuery method on the client is only supported on entity sets and queryable service operations.

    In this case you will have to unfortunately construct the URL manually.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, December 7, 2011 2:33 PM
    Moderator
  • Ok thank you.

    My operation was returning a MyObject type and accepting 2 parameters. It crashed for the reason you explained. 

    I modified the returned type to IQueryable<MyObject> and it works now.

     

    When you say : "The CreateQuery method on the client is only supported on entity sets and queryable service operations" What do you mean by "Entity Sets" because I thought that was what I did by returning a MyObject (which is an entity type) ? 

    Thank you

    Monday, December 19, 2011 10:51 AM