locked
Problem with $expand and Silverlight Client RRS feed

Answers

  • From looking at the error (trying to add duplicate URIs during result processing), most likely this is a glitch in the client library's state manager, which is rudimentary at best. We're building a production-class one now, but the one we shipped in the CTP was a proof of concept and does have some issues like this.

     

    The cause of the issue, if it's what I'm guessing, is that you have duplicate related objects (e.g. more than one video is bound to the same category object). While that's perfectly reasonable, the library may be mistakenly trying to add the second one into the state manager when it should not.

     

    Are you by any chance using QueryOptions.Tracking? If so, you can try removing it; that might help as we wouldn't put results in the state manager. Of course, the problem with disabling tracking is that you can no longer use the results for the query for update.

     

    Pablo Castro

    Technical Lead

    Microsoft Corporation

    http://blogs.msdn.com/pablo

     

    Wednesday, October 10, 2007 9:05 PM
    Moderator

All replies

  • I first reproduced this with the following query which only expands one child collection, but has the orderby, top and expand in the same order as your query.

     

    http://localhost:50000/WebDataService1.svc/ProductCategory?$orderby=Name&$top=5&$expand=Product

     

    Then used it in my already working silverlight app in place of a call that was just getting ProductCategory

     

    WebDataQuery<Category> q = _ctx.CreateQuery<Category>("/ProductCategory?$orderby=Name&$top=5&$expand=Product", QueryOption.IgnoreMissingProperties);

     

    And it did not throw an exception.

     

    Then I tried a query that expands two references, though only one is a collection SalesOrderDetails), the other (ProductModel) is a only a reference.

     

    http://localhost:50000/WebDataService1.svc/Product?$orderby=Name&$top=5&$expand=ProductModel,SalesOrderDetail

     

    In my client app that looks like this:

     

    WebDataQuery<Product> q = _ctx.CreateQuery<Product>(string.Format("/Product?$orderby=Name&$top=5&$expand=ProductModel,SalesOrderDetail",catSelected.Tag), QueryOption.IgnoreMissingProperties);

     

    This also worked.

     

    i have to go trolling for data that better represents your schema because it looks like you are expanding TWO property collections (or is that "collection properties").

     

    Just as a test, does your query work if you take out one of the references in the expand?

     

    julie

     

    Sunday, October 7, 2007 6:22 PM
  •  

    Hi Julie

     

    Thanks four your reply.

     

    Both of the properties I'm trying to expand are collections, if I expand only one (any of them) it works fine, the problem comes only when I to expand both of them, even if I remove the top and orderby commands.

     

    Regards.

    Monday, October 8, 2007 2:55 PM
  • I have an inkling that I'd get the same results as you and the problem is:

     

    I guess it's really something for Pablo to respond to.

    Monday, October 8, 2007 4:05 PM
  • From looking at the error (trying to add duplicate URIs during result processing), most likely this is a glitch in the client library's state manager, which is rudimentary at best. We're building a production-class one now, but the one we shipped in the CTP was a proof of concept and does have some issues like this.

     

    The cause of the issue, if it's what I'm guessing, is that you have duplicate related objects (e.g. more than one video is bound to the same category object). While that's perfectly reasonable, the library may be mistakenly trying to add the second one into the state manager when it should not.

     

    Are you by any chance using QueryOptions.Tracking? If so, you can try removing it; that might help as we wouldn't put results in the state manager. Of course, the problem with disabling tracking is that you can no longer use the results for the query for update.

     

    Pablo Castro

    Technical Lead

    Microsoft Corporation

    http://blogs.msdn.com/pablo

     

    Wednesday, October 10, 2007 9:05 PM
    Moderator
  • Hi Pablo.

     

    Thanks for your answer, I'm using QueryOption.IgnoreMissingProperties in my properties, I remove it but didn’t help. I understand this is a problem with the Silverlight Client more than with Astoria, so I think I'll have to wait until a new release to solve my problem.

     

    Thanks and regards.

     

     

    Wednesday, October 10, 2007 10:27 PM