This topic has not yet been rated - Rate this topic

DataServiceContext Class

July 26, 2012

The DataServiceContext represents the runtime context of an Open Data Protocol (OData) service. OData 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 an OData service, are the two main classes in the client library.

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

Namespace:  System.Data.Services.Client
Assembly:  System.Data.Services.Client (in System.Data.Services.Client.dll)
[DataContractAttribute(IsReference = true)]
public class DataServiceContext

The DataServiceContext type exposes the following members.

  NameDescription
Public methodDataServiceContextInitializes a new instance of the DataServiceContext class by using the specified baseUri.
Top
  NameDescription
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 Open Data Protocol (OData) service.
Public propertyCredentialsGets or sets the authentication information that is used when you send a request to the data service.
Public propertyDataNamespaceGets 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 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 Open Data Protocol (OData) service.
Public propertyLinksGets the collection of all associations or links currently being tracked by the DataServiceContext object.
Public propertyMergeOptionGets or sets the synchronization option for receiving entities from an Open Data Protocol (OData) service.
Public propertyResolveNameGets or sets a function to override the default type resolution strategy used by the client library when sending entities to an Open Data Protocol (OData) 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 an Open Data Protocol (OData) service.
Public propertySaveChangesDefaultOptionsGets or sets the SaveChangesOptions values used by the BeginSaveChanges method.
Public propertyTypeSchemeGets or sets the URI that is used to indicate what type scheme is used by the service.
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 that 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 between the source and the specified target entity.
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 within the specified resource set.
Public methodBeginExecute<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<T>(DataServiceQueryContinuation<T>, AsyncCallback, Object)Asynchronously sends a request to the Open Data Protocol (OData) service to retrieve the next page of data in a paged query result.
Public methodBeginExecuteBatchAsynchronously submits a group of queries as a batch to the Open Data Protocol (OData) service.
Public methodBeginGetReadStreamAsynchronously gets binary property data for the specified entity as a data stream along with the specified message headers.
Public methodBeginLoadProperty(Object, String, AsyncCallback, Object)Begins the operation to load the value of the specified property from the Open Data Protocol (OData) service.
Public methodBeginLoadProperty(Object, String, DataServiceQueryContinuation, AsyncCallback, Object)Asynchronously loads a page of related entities from the Open Data Protocol (OData) service by using the supplied next link URI.
Public methodBeginLoadProperty(Object, String, Uri, AsyncCallback, Object)Asynchronously loads a page of related entities from the Open Data Protocol (OData) service by using the supplied next link URI.
Public methodBeginSaveChanges(AsyncCallback, Object)Asynchronously submits the pending changes to the Open Data Protocol (OData) service collected by the DataServiceContext since the last time changes were saved.
Public methodBeginSaveChanges(SaveChangesOptions, AsyncCallback, Object)Asynchronously submits the pending changes to the Open Data Protocol (OData) service collected by the DataServiceContext since the last time changes were saved.
Public methodCancelRequestCancels a request to the DataServiceContext.
Public methodCreateQuery<T>Creates an Open Data Protocol (OData) service query for data of a specified generic type.
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 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<TElement>Called to complete the BeginExecute.
Public methodEndExecuteBatchCalled to complete the BeginExecuteBatch.
Public methodEndGetReadStreamCalled to complete the asynchronous operation of retrieving a binary property as a stream.
Public methodEndLoadPropertyCalled to complete the BeginLoadProperty operation.
Public methodEndSaveChangesCalled to complete the BeginSaveChanges operation.
Public methodEquals (Inherited from Object.)
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 Open Data Protocol (OData) service metadata for the OData service.
Public methodGetReadStreamUriGets the URI that is used to return binary property data as a data stream.
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
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 new data stream as the binary property of an entity with the specified settings in the request message.
Public methodSetSaveStream(Object, Stream, Boolean, String, String)Sets a new data stream as the binary property of an entity. The specified Content-Type and Slug headers are included in the request message.
Public methodToString (Inherited from Object.)
Public methodTryGetEntity<TEntity>Tests 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 eventReadingEntityOccurs after the entity has been completely read into the target entity.
Public eventReadingResponseOccurs before the response message from the data service is read.
Public eventSendingRequestOccurs when a new HttpWebRequest has been created.
Public eventWritingEntityOccurs after an entity has been fully serialized into XML (Atom), and allows the developer to change the XML before it is sent.
Public eventWritingRequestOccurs before the request message to the data service is written.
Top

For more information about DataServiceContext and DataServiceQuery<TElement>, see Open Data Protocol (OData) Client for Windows Phone.

For examples that use DataServiceContext, see How to: Consume an OData Service for Windows Phone.

Windows Phone OS

Supported in: 7.1

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.