locked
Related items not expanding RRS feed

  • Question

  • Folks,

       I'm using a "school" database (frankly, I can't remember where I got it from...) in SQL 2005, when I give Astoria the following URL:

     

    http://localhost:50371/schoolservice.svc/Course[2021]

     

    I get:

     

      <?xml version="1.0" encoding="utf-8" ?>
    - <DataService xml:base="http://localhost:50371/schoolservice.svc">
    - <Course>
    - <Course uri="Course[2021]">
      <CourseID>2021</CourseID>
      <Title>Woodshop</Title>
      <StartDate>9/1/2007 12:00:00 AM</StartDate>
      <EndDate>9/1/2007 12:00:00 AM</EndDate>
      <Credits>2</Credits>
      <CourseInstructor href="Course[2021]/CourseInstructor" />
      <Enrollment href="Course[2021]/Enrollment" />
      </Course>
      </Course>
      </DataService>

     

    Now I want to expand the course instructor so that I can see the instructor's details in the same package of XML... The URL I'm using for that is:

     

    http://localhost:50371/schoolservice.svc/Course[2021]?$expand=CourseInstructor

    and I get a error 500. When I change the URL to:

     

    http://localhost:50371/schoolservice.svc/Course[2021]?$expand=Course.CourseInstructor

    I get basically the same content as the previously unexpanded XML.

     

    If I refer to the course instructor manually through the following URL , I get functioning XML:

     

    http://localhost:50371/schoolservice.svc/Course[2021]/CourseInstructor

     

    And I can carry it further by doing /Course[2021]/CourseInstructor/Person to get the name of the person who is teaching that course.

     

    Can someone please help me figure out what I'm doing wrong here and why Astoria isn't expanding my data? Thanks!

    Friday, July 13, 2007 1:27 PM

Answers

  • The correct syntax is: http://localhost:50371/schoolservice.svc/Course[2021]?$expand=CourseInstructor

     

    Can you check the connection string to the DB on your astoria service and ensure that MultipleActiveResultSet is set to true.  If this is not set, expand will fail with a 500 error code from the server.  You can either edit the connection string directly or when setting up a the DB conncetion via the UI in VS navigate to the “Connection Properties” window click on “Advanced”, locate the “MultipleActiveResultSets” option and set it to “True” 

     

     

    Friday, July 13, 2007 5:45 PM

All replies

  • The correct syntax is: http://localhost:50371/schoolservice.svc/Course[2021]?$expand=CourseInstructor

     

    Can you check the connection string to the DB on your astoria service and ensure that MultipleActiveResultSet is set to true.  If this is not set, expand will fail with a 500 error code from the server.  You can either edit the connection string directly or when setting up a the DB conncetion via the UI in VS navigate to the “Connection Properties” window click on “Advanced”, locate the “MultipleActiveResultSets” option and set it to “True” 

     

     

    Friday, July 13, 2007 5:45 PM
  • That did the trick. Given the nature of Astoria, I would think that the MSFT folks would want to enable MARS by default on data services. I'm up and running now Smile

     

    I edited my connection string the old fashioned way with the text editor, but it's good to know that I can flip on MARS from the EDM DB wizard.

    Friday, July 13, 2007 5:49 PM
  • Good to hear and thanks for the feedback!
    Friday, July 13, 2007 5:52 PM