locked
retrieving data from odata service returns 0 records RRS feed

  • Question

  • Hi There,

    I wrote my first Odata consumer application. The service is running fine. I can retrieve data directly from web ui. But I could not get data through my silverlight application. The code is as follows.

    private void MainPage_Loaded(object sender, RoutedEventArgs e)

    {

    WarehouseModelContainer _context =new WarehouseModelContainer(new Uri("http://serviceuri"));

    DataServiceCollection<Task> _tasks= new DataServiceCollection<Task>();

    _tasks.LoadCompleted += DataLoaded;

    var query = ((from a in _context.Tasks select a).Take(10));

    _tasks.LoadAsync(query);

    }

    private void DataLoaded(object sender, LoadCompletedEventArgs e) { //do something }

     

    Debugging it, I found that in the Dataloaded function, the _tasks has no records.

    What is wrong with my code?

    Thanks.

    Wednesday, June 23, 2010 5:22 AM

Answers

All replies

  • Hi,

    Could you please try to use some network tracing tool (for example Fiddler) and see what request does the client make and what response it gets back?

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, June 23, 2010 11:26 AM
    Moderator
  • Thanks. Yes. This is a cross domain issue. I used Fiddler and found the problem. Following the following link, I solved the problem.

    http://msdn.microsoft.com/en-us/library/cc197955%28VS.95%29.aspx

    Friday, June 25, 2010 4:20 AM
  • The request did fail, but with the eveenting API there's no place for the library to throw an exception. So instead we pass the exception on one of the members of the evet args parameter to your event handler.

    Thanks,


    Vitek Karas [MSFT]
    Friday, June 25, 2010 6:26 AM
    Moderator