DataServiceCollection<T>.LoadAsync Method

Asynchronously loads items into the collection, when it represents the navigation property of an entity.

Supported only by the WCF Data Services 5.0 client for Silverlight.

Namespace:  System.Data.Services.Client
Assembly:  Microsoft.Data.Services.Client.SL (in Microsoft.Data.Services.Client.SL.dll)

Syntax

'Declaration
Public Sub LoadAsync
'Usage
Dim instance As DataServiceCollection

instance.LoadAsync()
public void LoadAsync()
public:
void LoadAsync()
member LoadAsync : unit -> unit
public function LoadAsync()

Exceptions

Exception Condition
InvalidOperationException

When the collection does not belong to a parent entity.

-or-

When the parent entity is not tracked by the DataServiceContext.

-or-

When a previous call to LoadAsync is not yet complete.

Remarks

When you use the Add Service Reference dialog or the DataSvcUtil.exe tool with the /binding option to generate the client data service classes, navigation properties that return a collection are generated as instances of DataServiceCollection<T>. When an instance of DataServiceCollection<T> is obtained from such a property, the LoadAsync method is used to load the related entities from the data service into the collection.

Because the LoadAsync method is asynchronous, the method returns before a response to the data service is received. You must handle the LoadCompleted event to access the QueryOperationResponse<T> that contains information about the result of the load operation. Items are loaded into the collection when the load operation is complete, whether or not the LoadCompleted event is handled.

The LoadAsync method can be called only once on the UI thread. The method cannot be called again until after the LoadCompleted event is raised. The LoadCompleted event is raised whether or not the query succeeds.

See Also

Reference

DataServiceCollection<T> Class

LoadAsync Overload

System.Data.Services.Client Namespace