locked
Service operation limit navigation option RRS feed

  • Question

  • Hello there,

    I have two tables, Article and Author which are Associated throw a FK (AuthorId).

    I wrote a service operation,

     [WebGet] public IQueryable<Article> GetArticles(DateTime from, DateTime to)

    which returns all the article between the requested date, so far so good but when I want to continue navigate throw the objects i.e writing the following URI
    http://hostname/ServiceName.svc/GetArticles?from=datetime'2009-07-01'&to=datetime'2009-08-01'/Author

    I get bad request result, if I want to specifiy a specific article using reference key as follows

    http://hostname/ServiceName.svc/GetArticles?from=datetime'2009-07-01'&to=datetime'2009-08-01'(6)

    Still bad request

    But when I call a parameterless service's operation the URIs above  will work
      
    Is there a problem with navigation after calling a service operation with parameters ? am I doing something wrong ? how can I solve this issues ?
     
    it's very urgent and it might affect my decision to drop this project
    Thursday, August 13, 2009 7:07 AM

Answers

  • Hi Ron,

     a) Is subjective , we allow you to compose further queries from the result of a ServiceOperation that returns an IQueryable<EntityType> ,  
          So , if your service operation did not accept any input parameters , then  /GetArticles(6) would have worked . But  , since you do need the parameters "fromDate"
             and "to" to be sent to the service operation, this query would fail .

      b) Navigation properties should work the same with any kind of service operation , what kind of problems did you face with Service Operations that expect parameters.
      c) I assumed that "Author" was an entity type and not a field, you can correct me if I was wrong .


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Thursday, August 13, 2009 5:20 PM
    Moderator

All replies

  • Hi,
     The uri format you are using to access the navigation property is incorrect.
     Try expanding the navigation property you want to have access to :
     
    http://hostname/ServiceName.svc/GetArticles?from=datetime'2009-07-01'&to=datetime'2009-08-01'&$expand=Author

    this way , the Article objects returned to you have the Author field filled in .

    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Thursday, August 13, 2009 4:52 PM
    Moderator
  • Hi there,

    Thanks for your reply, It implies that:
    a)If I want to get a specific article  I must append ?$filter=ArticeId eq 6 and not (6)
    b)When I used a service operation which doesn't excpect parameters the navigation property works quite well.
    c)Author is an entity not a field

    Thanks, 

    Ronchuk   
    Thursday, August 13, 2009 5:01 PM
  • Hi Ron,

     a) Is subjective , we allow you to compose further queries from the result of a ServiceOperation that returns an IQueryable<EntityType> ,  
          So , if your service operation did not accept any input parameters , then  /GetArticles(6) would have worked . But  , since you do need the parameters "fromDate"
             and "to" to be sent to the service operation, this query would fail .

      b) Navigation properties should work the same with any kind of service operation , what kind of problems did you face with Service Operations that expect parameters.
      c) I assumed that "Author" was an entity type and not a field, you can correct me if I was wrong .


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Thursday, August 13, 2009 5:20 PM
    Moderator