DataServiceQuery<TElement>::AddQueryOption Method (String^, Object^)

 
System_CAPS_noteNote

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

Creates a new DataServiceQuery<TElement> with the query option set in the URI generated by the returned query.

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

public:
DataServiceQuery<TElement>^ AddQueryOption(
	String^ name,
	Object^ value
)

Parameters

name
Type: System::String^

The string value that contains the name of the query string option to add.

value
Type: System::Object^

The object that contains the value of the query string option.

Return Value

Type: System.Data.Services.Client::DataServiceQuery<TElement>^

A new query that includes the requested query option appended to the URI of the supplied query

The query options are added to the resultant URI using ?name=value&name2=value2… syntax where the name maps directly to the name parameter and the value is obtained by calling ToString on the value parameter. The name starts with $.

Non-WCF Data Services syntax does not start with $. Non-WCF Data Services query options can be added using this method. It is legal to add the same query option twice if the option is not an WCF Data Services query option. If a query option is added that is already present in the underlying URI, an exception is thrown.

The following example shows a DataServiceQuery<TElement> that is used with sequential AddQueryOption method calls to only return orders with a freight cost of more than $30 and to order the results by the ship date in descending order.

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

The following example shows how to compose a LINQ query that is equivalent to the previous query that used AddQueryOption.

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

.NET Framework
Available since 3.5
Silverlight
Available since 2.0
Return to top
Show: