DataServiceContext::Execute<TElement> Method (Uri^)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Sends a request to the data service to execute a specific URI.

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

generic<typename TElement>
IEnumerable<TElement>^ Execute(
	Uri^ requestUri


Type: System::Uri^

The URI to which the query request will be sent. The URI may be any valid data service URI. Can contain $ query parameters.

Return Value

Type: System.Collections.Generic::IEnumerable<TElement>^

The results of the query operation.

Type Parameters


The type that the query returns.

Exception Condition

When a response is not received from a request to the requestUri.


When requestUri is null.


When requestUri is not a valid URI for the data service.


When an error is raised either during execution of the request or when it converts the contents of the response message into objects.


When the data service returns an HTTP 404: Resource Not Found error.

The Execute<TElement> method is used to query a data service by URI; the method causes an HTTP GET request to be issued to the data service. The request URI specified can be absolute or relative.

If the requestUri is absolute, this method validates whether the URI points to the same data service that was specified when constructing the DataServiceContext. If the requestUri is relative, this method strips off any leading slashes and appends requestUri to what was provided when constructing the DataServiceContext. A slash is appended after the URI passed to the DataServiceContext constructor, if one is not already present.

When this method returns, all of the HTTP response for the request has been read from the network stream, but the response will not have been processed; there is no identity resolution or object materialization. Identity resolution and full object materialization do not occur for a specified entity in the response until it is enumerated.

This example uses a do…while loop to load Customers entities from a paged results from the data service. The Execute<TElement> method is called by using the next link URI to receive the next page of data.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.5
Return to top