locked
Serviceoperation addqueryoption error RRS feed

  • Question

  • i Have a serviceoperation like this :
            [WebGet]
    
            public bool ExistsUID(int uID)
    
            {
                return new ManageUsers().ExistsUID(uID);
            }
    
    
    
    
    And call it like this:
    Uri u = new Uri(string.Format("{0}/ExistsUID?uID={1}", db.BaseUri, 0), UriKind.RelativeOrAbsolute);
    
                var g = db.Execute<bool>(u);
    
    
    
    
    Everithing Works fine like that way, but if i try to call like this:
                var f = ContextDataService.CreateQuery<bool>("ExistsUID").AddQueryOption("uID", 3);
    
                f.BeginExecute(x =>
                    {
    
                      IEnumerable<bool> c = f.EndExecute(x);
    
                      bool g = c.ToList().FirstOrDefault();
                    }, f);
    
    
    
    
    I get an error because the URL is being formatted like this:
    http://xxx/DataService1.svc/ExistsUID()?uID=1   //Note the parenthesis

    And it throws an error because the parethesis must not go in a service operation.

    if i dont add a ".AddQueryOption" the url is like this:
    http://xxx/DataService1.svc/ExistsUID //no parethesis

    Now the question, is there any way to add parameters to a service operation and the url will be formatted correctly???

    Make it Ice
    • Edited by Spidey Thursday, March 18, 2010 4:31 PM removed link
    Thursday, March 18, 2010 4:30 PM

Answers

  • Hi Spidey,

    public DataServiceQuery<T> CreateQuery<T>(string entitySetName) method is not a suported way of calling service operations. If what you want is doing async execute with a URI you can use the following method:

    public IAsyncResult BeginExecute<TElement>(
        Uri requestUri,
        AsyncCallback callback,
        Object state
    )

     

    http://msdn.microsoft.com/en-us/library/cc646724.aspx

    Regards,


    [MSFT] Sih Huseyin Ulger
    Friday, March 19, 2010 2:57 PM

All replies

  • Hi Spidey,

    public DataServiceQuery<T> CreateQuery<T>(string entitySetName) method is not a suported way of calling service operations. If what you want is doing async execute with a URI you can use the following method:

    public IAsyncResult BeginExecute<TElement>(
        Uri requestUri,
        AsyncCallback callback,
        Object state
    )

     

    http://msdn.microsoft.com/en-us/library/cc646724.aspx

    Regards,


    [MSFT] Sih Huseyin Ulger
    Friday, March 19, 2010 2:57 PM
  • Hi Spidey,

    public DataServiceQuery<T> CreateQuery<T>(string entitySetName) method is not a suported way of calling service operations. If what you want is doing async execute with a mp4 you can use the following method:

    public IAsyncResult BeginExecute<TElement>(
        Uri requestUri,
        AsyncCallback callback,
        Object state
    )

     

    http://msdn.microsoft.com/en-us/library/cc646724.aspx

    Regards,


    [MSFT] Sih Huseyin Ulger

    Thanks for your reply. I encountered the same error. Your info is very helpful to me.
    Friday, July 16, 2010 3:27 AM