Archive

Posts Tagged ‘OData’

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));
Categories: .NET, C#, OData, Services, WCF Tags: , , ,