The DataServiceContext represents the runtime context of the data service.
Namespace:
System.Data.Services.Client
Assembly:
System.Data.Services.Client (in System.Data.Services.Client.dll)
'Usage
Dim instance As DataServiceContext
'Declaration
Public Class DataServiceContext
This topic describes new functionality in ADO.NET Data Services that is available as an update to the .NET Framework version 3.5 Service Pack 1. You can download and install the update from the Microsoft Download Center.
ADO.NET Data Services are stateless, but the DataServiceContext is not. State on the client is maintained between interactions in order to support features such as update management. This class, and the DataServiceQuery class that represents a particular HTTP request to a data service, are the two main classes in the client library.
The following example shows how to use the DataServiceContext generated by the Add Service Reference tool to implicitly execute a query against the Northwind data service that returns all customers. The URI of the requested Customers entity set is determined automatically by the context. The query is executed implicitly when the enumeration occurs. The Northwind data service is created when you complete the ADO.NET Data Services quickstart.
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)
' Define a new query for Customers.
Dim query As DataServiceQuery(Of Customers) = context.Customers
Try
' Enumerate over the query result, which is executed implicitly.
For Each customer As Customers In query
Console.WriteLine("Customer Name: {0}", customer.CompanyName)
Next
Catch ex As Exception
Throw New ApplicationException( _
"An error occurred during query execution.", ex)
End Try
System..::.Object
System.Data.Services.Client..::.DataServiceContext
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5 SP1
Reference
Other Resources