SALES: 1-800-867-1380
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataServiceContext Class

The DataServiceContext represents the runtime context of the data service.

System.Object
  System.Data.Services.Client.DataServiceContext

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

'Declaration
Public Class DataServiceContext
'Usage
Dim instance As DataServiceContext

The DataServiceContext type exposes the following members.

  NameDescription
Public methodDataServiceContextInitializes a new instance of the DataServiceContext class.
Public methodDataServiceContext(Uri)Initializes a new instance of the DataServiceContext class with the specified serviceRoot.
Public methodDataServiceContext(Uri, DataServiceProtocolVersion)Initializes a new instance of the DataServiceContext class with the specified serviceRoot and targeting the specific maxProtocolVersion.
Top

  NameDescription
Public propertyAddAndUpdateResponsePreferenceGets or sets whether the client requests that the data service return entity data in the response message to a change request.
Public propertyApplyingChangesGets a value that indicates whether the DataServiceContext is currently applying changes to tracked objects.
Public propertyBaseUriGets the absolute URI identifying the root of the target data service.
Public propertyConfigurationsGets the configurations.
Public propertyCredentialsGets or sets the authentication information that is used by each query created by using the DataServiceContext object.
Public propertyDataNamespace Obsolete. Gets or sets the XML namespace for data items, not metadata items, of an Atom payload.
Public propertyEntitiesGets a list of all the resources currently being tracked by the DataServiceContext.
Public propertyFormatGets an object which allows the user to customize the format the client will use for making requests.
Public propertyIgnoreMissingPropertiesGets or sets whether the properties read from the type must be mapped to properties on the client-side type.
Public propertyIgnoreResourceNotFoundExceptionGets or sets whether an exception is raised when a 404 error (resource not found) is returned by the data service.
Public propertyLinksGets the collection of all associations or links currently being tracked by the DataServiceContext object.
Public propertyMaxProtocolVersionGets the maximum version of the Open Data Protocol (OData) that the client is allowed to use.
Public propertyMergeOptionGets or sets the synchronization option for receiving entities from a data service.
Public propertyResolveEntitySetGets or sets the delegate method that is used to resolve the entity set URI when the value cannot be determined from an edit-link or self-link URI.
Public propertyResolveNameGets or sets a function to override the default type resolution strategy used by the client library when you send entities to a data service.
Public propertyResolveTypeGets or sets a function that is used to override the default type resolution option that is used by the client library when receiving entities from a data service.
Public propertySaveChangesDefaultOptionsGets or sets the SaveChangesOptions values that are used by the SaveChanges method.
Public propertyTimeoutGets or sets the time-out option (in seconds) that is used for the underlying HTTP request to the data service.
Public propertyTypeScheme Obsolete. Gets or sets the URI used to indicate what type scheme is used by the service.
Public propertyUrlConventionsGets or sets the URL conventions the client should use.
Public propertyUsePostTunnelingGets or sets a Boolean value that indicates whether to use post tunneling.
Top

  NameDescription
Public methodAddLinkAdds the specified link to the set of objects the DataServiceContext is tracking.
Public methodAddObjectAdds the specified object to the set of objects that the DataServiceContext is tracking.
Public methodAddRelatedObjectAdds a related object to the context and creates the link that defines the relationship between the two objects in a single request.
Public methodAttachLinkNotifies the DataServiceContext to start tracking the specified link that defines a relationship between entity objects.
Public methodAttachTo(String, Object)Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource within the specified resource set.
Public methodAttachTo(String, Object, String)Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource in the specified resource set.
Public methodBeginExecute(Uri, AsyncCallback, Object, String, OperationParameter())Asynchronously sends a request to the data service to execute a specific URI.
Public methodBeginExecute(Of TElement)(Uri, AsyncCallback, Object)Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.
Public methodBeginExecute(Of T)(DataServiceQueryContinuation(Of T), AsyncCallback, Object)Asynchronously sends a request to the data service to retrieve the next page of data in a paged query result.
Public methodBeginExecute(Of TElement)(Uri, AsyncCallback, Object, String, Boolean, OperationParameter())Asynchronously sends a request to the data service to execute a specific URI.
Public methodBeginExecuteBatchAsynchronously submits a group of queries as a batch to the data service.
Public methodBeginGetReadStream(Object, DataServiceRequestArgs, AsyncCallback, Object)Asynchronously gets the binary data stream that belongs to the specified entity, by using the specified message headers.
Public methodBeginGetReadStream(Object, String, DataServiceRequestArgs, AsyncCallback, Object)Asynchronously gets a named binary data stream that belongs to the specified entity, by using the specified message headers.
Public methodBeginLoadProperty(Object, String, AsyncCallback, Object)Asynchronously loads the value of the specified property from the data service.
Public methodBeginLoadProperty(Object, String, DataServiceQueryContinuation, AsyncCallback, Object)Asynchronously loads the next page of related entities from the data service by using the supplied query continuation object.
Public methodBeginLoadProperty(Object, String, Uri, AsyncCallback, Object)Asynchronously loads a page of related entities from the data service by using the supplied next link URI.
Public methodBeginSaveChanges(AsyncCallback, Object)Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.
Public methodBeginSaveChanges(SaveChangesOptions, AsyncCallback, Object)Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.
Public methodCancelRequestAttempts to cancel the operation that is associated with the supplied IAsyncResult object.
Public methodChangeStateChanges the state of the given entity. Note that the 'Added' state is not supported by this method, and that AddObject or AddRelatedObject should be used instead. If the state 'Modified' is given, calling this method is exactly equivalent to calling UpdateObject. If the state 'Deleted' is given, calling this method is exactly equivalent to calling DeleteObject. If the state 'Detached' is given, calling this method is exactly equivalent to calling Detach. If the state 'Unchanged' is given, the state will be changed, but no other modifications will be made to the entity or entity descriptor associated with it.
Public methodCreateQuery(Of T)Creates a data service query for data of a specified generic type.
Protected methodDefaultResolveTypeDetermines the type that
Public methodDeleteLinkChanges the state of the link to deleted in the list of links being tracked by the DataServiceContext.
Public methodDeleteObjectChanges the state of the specified object to be deleted in the DataServiceContext.
Public methodDetachRemoves the entity from the list of entities that the DataServiceContext is tracking.
Public methodDetachLinkRemoves the specified link from the list of links being tracked by the DataServiceContext.
Public methodEndExecute(IAsyncResult)Called to complete the BeginExecute.
Public methodEndExecute(Of TElement)(IAsyncResult)Called to complete the BeginExecute.
Public methodEndExecuteBatchCalled to complete the BeginExecuteBatch.
Public methodEndGetReadStreamCalled to complete the asynchronous operation of retrieving a binary data stream.
Public methodEndLoadPropertyCalled to complete the BeginLoadProperty operation.
Public methodEndSaveChangesCalled to complete the BeginSaveChanges operation.
Public methodEquals (Inherited from Object.)
Public methodExecute(Uri, String, OperationParameter())Sends a request to the data service to execute a specific URI by using a specific HTTP method.
Public methodExecute(Of TElement)(Uri)Sends a request to the data service to execute a specific URI.
Public methodExecute(Of T)(DataServiceQueryContinuation(Of T))Sends a request to the data service to retrieve the next page of data in a paged query result.
Public methodExecute(Of TElement)(Uri, String, Boolean, OperationParameter())Sends a request to the data service to execute a specific URI by using a specific HTTP method.
Public methodExecuteBatchSynchronously submits a group of queries as a batch to the data service.
Protected methodFinalize (Inherited from Object.)
Public methodGetEntityDescriptorGets the EntityDescriptor for the supplied entity object.
Public methodGetHashCode (Inherited from Object.)
Public methodGetLinkDescriptorGets the LinkDescriptor for a specific link that defines the relationship between two entities.
Public methodGetMetadataUriGets a URI of the location of .edmx metadata.
Public methodGetReadStream(Object)Gets the binary data stream that belongs to the specified entity.
Public methodGetReadStream(Object, DataServiceRequestArgs)Gets binary data stream for the specified entity by using the specified message headers.
Public methodGetReadStream(Object, String)Gets the binary data stream that belongs to the specified entity, by using the specified Content-Type message header.
Public methodGetReadStream(Object, String, DataServiceRequestArgs)Gets a named binary data stream that belongs to the specified entity, by using the specified Content-Type message header.
Public methodGetReadStreamUri(Object)Gets the URI that is used to return a binary data stream.
Public methodGetReadStreamUri(Object, String)Gets the URI that is used to return a named binary data stream.
Public methodGetType (Inherited from Object.)
Public methodLoadProperty(Object, String)Loads deferred content for a specified property from the data service.
Public methodLoadProperty(Object, String, DataServiceQueryContinuation)Loads the next page of related entities from the data service by using the supplied query continuation object.
Public methodLoadProperty(Object, String, Uri)Loads a page of related entities by using the supplied next link URI.
Public methodLoadProperty(Of T)(Object, String, DataServiceQueryContinuation(Of T))Loads the next page of related entities from the data service by using the supplied generic query continuation object.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodSaveChangesSaves the changes that the DataServiceContext is tracking to storage.
Public methodSaveChanges(SaveChangesOptions)Saves the changes that the DataServiceContext is tracking to storage.
Public methodSetLinkNotifies the DataServiceContext that a new link exists between the objects specified and that the link is represented by the property specified by the sourceProperty parameter.
Public methodSetSaveStream(Object, Stream, Boolean, DataServiceRequestArgs)Sets a binary data stream for the specified entity, with the specified headers in the request message.
Public methodSetSaveStream(Object, Stream, Boolean, String, String)Sets a binary data stream that belongs to the specified entity, with the specified Content-Type and Slug headers in the request message.
Public methodSetSaveStream(Object, String, Stream, Boolean, DataServiceRequestArgs)Sets a named binary data stream that belongs to the specified entity, with the specified headers in the request message.
Public methodSetSaveStream(Object, String, Stream, Boolean, String)Sets a binary data stream for the specified entity.
Public methodToString (Inherited from Object.)
Public methodTryGetEntity(Of TEntity)Test retrieval of an entity being tracked by the DataServiceContext by reference to the URI of the entity.
Public methodTryGetUriRetrieves the canonical URI associated with the specified entity, if available.
Public methodUpdateObjectChanges the state of the specified object in the DataServiceContext to Modified.
Top

  NameDescription
Public eventBuildingRequestThis event is fired before a request message object is built, giving the handler the opportunity to inspect, adjust and/or replace some request information before the message is built. This event should be used to modify the outgoing Url of the request or alter request headers. After the request is built, other modifications on the WebRequest object can be made in SendingRequest2.
Public eventReadingEntityOccurs after entity data has been completely read into the entity object.
Public eventReceivingResponseThis event fires when a response is received by the client. It fires for both top level responses and each operation or query within a batch response.
Public eventSendingRequest Obsolete. Occurs when a new HttpWebRequest has been created.
Public eventSendingRequest2Occurs when a new HttpWebRequest has been created.
Public eventWritingEntityOccurs after an entity has been fully serialized into XML in a request message.
Top

WCF 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft