Поделиться через


DataServiceContext Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

The DataServiceContext represents the runtime context of an WCF Data Services. 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.

Inheritance Hierarchy

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

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

Syntax

'Declaration
Public Class DataServiceContext
public class DataServiceContext

The DataServiceContext type exposes the following members.

Constructors

  Name Description
Public method DataServiceContext Initializes a new instance of the DataServiceContext class by using the specified baseURI.

Top

Properties

  Name Description
Public property ApplyingChanges Gets a value that indicates whether the DataServiceContext is currently applying changes to tracked objects.
Public property BaseUri Gets the absolute URI identifying the root of the target data service.
Public property Credentials Gets or sets the authentication information that is used when you send a request to the data service.
Public property DataNamespace Gets or sets the XML namespace for data items, not metadata items, of an Atom payload.
Public property Entities Gets a list of all the resources currently being tracked by the DataServiceContext.
Public property HttpStack Gets a value that indicates the type of HTTP implementation to use when accessing the data service.
Public property IgnoreMissingProperties Gets or sets whether the properties read from the type must be mapped to properties on the client-side type.
Public property IgnoreResourceNotFoundException Gets or sets whether an exception is raised when a 404 error (resource not found) is returned by the data service.
Public property Links Gets the collection of all associations or links currently being tracked by the DataServiceContext object.
Public property MergeOption Gets or sets the synchronization option for receiving entities from a data service.
Public property ResolveName Gets or sets a function to override the default type resolution strategy used by the client library when sending entities to a data service.
Public property ResolveType Gets 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 property SaveChangesDefaultOptions Gets or sets the SaveChangesOptions values used by the BeginSaveChanges method.
Public property TypeScheme Gets or sets the URI that is used to indicate what type scheme is used by the service.
Public property UseDefaultCredentials Gets or sets whether default credentials are used to authenticate requests to the data service.
Public property UsePostTunneling Gets or sets a Boolean value that indicates whether to use post tunneling.

Top

Methods

  Name Description
Public method AddLink Adds the specified link to the set of objects the DataServiceContext is tracking.
Public method AddObject Adds the specified object to the set of objects that the DataServiceContext is tracking.
Public method AddRelatedObject Adds a related object to the context and creates the link that defines the relationship between the two objects in a single request.
Public method AttachLink Notifies the DataServiceContext to start tracking the specified link between the source and the specified target entity.
Public method AttachTo(String, Object) Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource within the specified resource set.
Public method AttachTo(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 method BeginExecute<T>(DataServiceQueryContinuation<T>, AsyncCallback, Object) Asynchronously sends a request to the data service to retrieve the next page of data in a paged query result.
Public method BeginExecute<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 method BeginExecuteBatch Asynchronously submits a group of queries as a batch to the data service.
Public method BeginGetReadStream Asynchronously gets binary property data for the specified entity as a data stream along with the specified message headers.
Public method BeginLoadProperty(Object, String, AsyncCallback, Object) Begins the operation to load the value of the specified property from the data service.
Public method BeginLoadProperty(Object, String, DataServiceQueryContinuation, AsyncCallback, Object) Asynchronously loads a page of related entities from the data service by using the supplied next link URI.
Public method BeginLoadProperty(Object, String, Uri, AsyncCallback, Object) Asynchronously loads a page of related entities from the data service by using the supplied next link URI.
Public method BeginSaveChanges(AsyncCallback, Object) Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.
Public method BeginSaveChanges(SaveChangesOptions, AsyncCallback, Object) Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.
Public method CancelRequest Cancels a request to the DataServiceContext.
Public method CreateQuery<T> Creates a data service query for data of a specified generic type.
Public method DeleteLink Changes the state of the link to Deleted in the list of links being tracked by the DataServiceContext.
Public method DeleteObject Changes the state of the specified object to Deleted in the DataServiceContext.
Public method Detach Removes the entity from the list of entities that the DataServiceContext is tracking.
Public method DetachLink Removes the specified link from the list of links being tracked by the DataServiceContext.
Public method EndExecute<TElement> Called to complete the BeginExecute.
Public method EndExecuteBatch Called to complete the BeginExecuteBatch.
Public method EndGetReadStream Called to complete the asynchronous operation of retrieving a binary property as a stream.
Public method EndLoadProperty Called to complete the BeginLoadProperty operation.
Public method EndSaveChanges Called to complete the BeginSaveChanges operation.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public method GetEntityDescriptor Gets the EntityDescriptor for the supplied entity object.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLinkDescriptor Gets the LinkDescriptor for a specific link that defines the relationship between two entities.
Public method GetMetadataUri Gets a URI of the data service metadata for the data service.
Public method GetReadStreamUri Gets the URI that is used to return binary property data as a data stream.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method SetLink Notifies 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 method SetSaveStream(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 method SetSaveStream(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 method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method TryGetEntity<TEntity> Tests retrieval of an entity being tracked by the DataServiceContext by reference to the URI of the entity.
Public method TryGetUri Retrieves the canonical URI associated with the specified entity, if available.
Public method UpdateObject Changes the state of the specified object in the DataServiceContext to Modified.

Top

Events

  Name Description
Public event ReadingEntity Occurs after the entity has been completely read into the target entity.
Public event SendingRequest Occurs when a new HttpWebRequest has been created.
Public event WritingEntity Occurs after an entity has been fully serialized into XML (Atom), and allows the developer to change the XML before it is sent.

Top

Remarks

For more information about DataServiceContext and DataServiceQuery<TElement>, see Creating the Client Application (WCF Data Services/Silverlight).

Examples

For examples that use DataServiceContext, see WCF Data Services (Silverlight).

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

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