Home > .NET, C#, OData, Services, WCF > WCF Data Service Exception: The LoadAsync method cannot be called when the DataServiceCollection is not a child collection of a related entity

WCF Data Service Exception: The LoadAsync method cannot be called when the DataServiceCollection is not a child collection of a related entity


In code you most likely called the no argument LoadAsync() method. Make sure you call pass the correcgt URI to the LoadAsync method. For example: if you service is located at http://localhost:1033/Services/PersonInfoService.svc/People

Make sure you pass the service URI without /People to the service context and pass /People to to the LoadAsync method

var people = new PersonEntities(new Uri("http://localhost:1033/Services/PersonInfoService.svc/"));
var Items = new DataServiceCollection<Person>(people);
//Pass the collection path to the LoadAsync method
Items.LoadAsync(new Uri("/People", UriKind.Relative));
Advertisements
Categories: .NET, C#, OData, Services, WCF Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: