Share via


DataServiceContext Class

Definition

The DataServiceContext represents the runtime context of the data service.

public class DataServiceContext
type DataServiceContext = class
Public Class DataServiceContext
Inheritance
DataServiceContext

Constructors

DataServiceContext()

Initializes a new instance of the DataServiceContext class.

DataServiceContext(Uri, ODataProtocolVersion)

Initializes a new instance of the DataServiceContext class with the specified serviceRoot and targeting the specific maxProtocolVersion.

DataServiceContext(Uri)

Initializes a new instance of the DataServiceContext class with the specified serviceRoot.

Properties

AddAndUpdateResponsePreference

Gets or sets whether the client requests that the data service return entity data in the response message to a change request.

ApplyingChanges

Gets a value that indicates whether the DataServiceContext is currently applying changes to tracked objects.

BaseUri

Gets the absolute URI identifying the root of the target data service.

Configurations

Gets the configurations.

Credentials

Gets or sets the authentication information that is used by each query created by using the DataServiceContext object.

DisableInstanceAnnotationMaterialization

Disable instance annotation to be materialized.

EnableWritingODataAnnotationWithoutPrefix

Whether enable writing odata annotation without prefix.

Entities

Gets a list of all the resources currently being tracked by the DataServiceContext.

EntityParameterSendOption

Gets or sets the option for sending entity parameters to service.

EntityTracker

Returns the instance of entity tracker which tracks all the entities and links tracked by the context.

Format

Gets an object which allows the user to customize the format the client will use for making requests.

HttpRequestTransportMode

Gets or sets the HttpRequest mode to use in making Http Requests.

IgnoreResourceNotFoundException

Gets or sets whether an exception is raised when a 404 error (resource not found) is returned by the data service.

KeyComparisonGeneratesFilterQuery

Indicates whether a Where clause that just compares the key property generates a $filter query option.

Links

Gets the collection of all associations or links currently being tracked by the DataServiceContext object.

MaxProtocolVersion

Gets the maximum version of the Open Data Protocol (OData) that the client is allowed to use.

MergeOption

Gets or sets the synchronization option for receiving entities from a data service.

ReadWriteTimeout

Gets or sets the readwrite time-out option (in seconds) that is used for the underlying HTTP request to the data service.

ResolveEntitySet

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

ResolveName

Gets or sets a function to override the default type resolution strategy used by the client library when you send entities to a data service.

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.

SaveChangesDefaultOptions

Gets or sets the SaveChangesOptions values that are used by the SaveChanges(SaveChangesOptions) method.

Timeout

Gets or sets the time-out option (in seconds) that is used for the underlying HTTP request to the data service.

UrlKeyDelimiter

Gets or sets the URL key delimiter the client should use.

UsePostTunneling

Gets or sets a Boolean value that indicates whether to use post tunneling.

Methods

AddLink(Object, String, Object)

Adds the specified link to the set of objects the DataServiceContext is tracking.

AddObject(String, Object)

Adds the specified object to the set of objects that the DataServiceContext is tracking.

AddRelatedObject(Object, String, Object)

Adds a related object to the context and creates the link that defines the relationship between the two objects in a single request.

AttachLink(Object, String, Object)

Notifies the DataServiceContext to start tracking the specified link that defines a relationship between entity objects.

AttachTo(String, Object, String)

Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource in the specified resource set.

AttachTo(String, Object)

Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource within the specified resource set.

BeginExecute(Uri, AsyncCallback, Object, String, OperationParameter[])

Asynchronously sends a request to the data service to execute a specific URI.

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.

BeginExecute<TElement>(Uri, AsyncCallback, Object, String, Boolean, OperationParameter[])

Asynchronously sends a request to the data service to execute a specific URI.

BeginExecute<TElement>(Uri, AsyncCallback, Object, String, OperationParameter[])

Asynchronously sends a request to the data service to execute a specific URI.

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.

BeginExecuteBatch(AsyncCallback, Object, DataServiceRequest[])

Asynchronously submits a group of queries as a batch to the data service.

BeginExecuteBatch(AsyncCallback, Object, SaveChangesOptions, DataServiceRequest[])

Asynchronously submits a group of queries as a batch to the data service.

BeginGetReadStream(Object, DataServiceRequestArgs, AsyncCallback, Object)

Asynchronously gets the binary data stream that belongs to the specified entity, by using the specified message headers.

BeginGetReadStream(Object, String, DataServiceRequestArgs, AsyncCallback, Object)

Asynchronously gets a named binary data stream that belongs to the specified entity, by using the specified message headers.

BeginLoadProperty(Object, String, AsyncCallback, Object)

Asynchronously loads the value of the specified property from the data service.

BeginLoadProperty(Object, String, DataServiceQueryContinuation, AsyncCallback, Object)

Asynchronously loads the next page of related entities from the data service by using the supplied query continuation object.

BeginLoadProperty(Object, String, Uri, AsyncCallback, Object)

Asynchronously loads a page of related entities from the data service by using the supplied next link URI.

BeginSaveChanges(AsyncCallback, Object)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

BeginSaveChanges(SaveChangesOptions, AsyncCallback, Object)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

CancelRequest(IAsyncResult)

Attempts to cancel the operation that is associated with the supplied IAsyncResult object.

ChangeState(Object, EntityStates)

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

CreateFunctionQuery<T>()

Creates a data service query for a function invocation that returns a specified generic type.

CreateFunctionQuery<T>(String, String, Boolean, UriOperationParameter[])

Creates a data service query for function which return collection of data.

CreateFunctionQuerySingle<T>(String, String, Boolean, UriOperationParameter[])

Creates a data service single query for function which return single data.

CreateQuery<T>(String, Boolean)

Creates a data service query for a function with return type in a specified generic type.

CreateQuery<T>(String)

Creates a data service query for data of a specified generic type.

CreateSingletonQuery<T>(String)

Creates a data service query for singleton data of a specified generic type.

DefaultResolveType(String, String, String)

Determines the type that

DeleteLink(Object, String, Object)

Changes the state of the link to deleted in the list of links being tracked by the DataServiceContext.

DeleteObject(Object, Object[])

Changes the state of the specified object to be deleted in the DataServiceContext.

DeleteObject(Object)

Changes the state of the specified object to be deleted in the DataServiceContext.

Detach(Object)

Removes the entity from the list of entities that the DataServiceContext is tracking.

DetachLink(Object, String, Object)

Removes the specified link from the list of links being tracked by the DataServiceContext.

EndExecute(IAsyncResult)

Called to complete the BeginExecute<TElement>(Uri, AsyncCallback, Object).

EndExecute<TElement>(IAsyncResult)

Called to complete the BeginExecute<TElement>(Uri, AsyncCallback, Object).

EndExecuteBatch(IAsyncResult)

Called to complete the BeginExecuteBatch(AsyncCallback, Object, DataServiceRequest[]).

EndGetReadStream(IAsyncResult)

Called to complete the asynchronous operation of retrieving a binary data stream.

EndLoadProperty(IAsyncResult)

Called to complete the BeginLoadProperty(Object, String, AsyncCallback, Object) operation.

EndSaveChanges(IAsyncResult)

Called to complete the BeginSaveChanges(AsyncCallback, Object) operation.

Execute(Uri, String, OperationParameter[])

Sends a request to the data service to execute a specific URI by using a specific HTTP method.

Execute<T>(DataServiceQueryContinuation<T>)

Sends a request to the data service to retrieve the next page of data in a paged query result.

Execute<TElement>(Uri, String, Boolean, OperationParameter[])

Sends a request to the data service to execute a specific URI by using a specific HTTP method.

Execute<TElement>(Uri, String, OperationParameter[])

Sends a request to the data service to execute a specific URI by using a specific HTTP method.

Execute<TElement>(Uri)

Sends a request to the data service to execute a specific URI.

ExecuteAsync(Uri, String, CancellationToken, OperationParameter[])

Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.

ExecuteAsync(Uri, String, OperationParameter[])

Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.

ExecuteAsync<TElement>(DataServiceQueryContinuation<TElement>, CancellationToken)

Asynchronously sends a request to the data service to retrieve the next page of data in a paged query result.

ExecuteAsync<TElement>(DataServiceQueryContinuation<TElement>)

Asynchronously sends a request to the data service to retrieve the next page of data in a paged query result.

ExecuteAsync<TElement>(Uri, CancellationToken)

Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.

ExecuteAsync<TElement>(Uri, String, Boolean, CancellationToken, OperationParameter[])

Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.

ExecuteAsync<TElement>(Uri, String, Boolean, OperationParameter[])

Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.

ExecuteAsync<TElement>(Uri, String, CancellationToken, OperationParameter[])

Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.

ExecuteAsync<TElement>(Uri, String, OperationParameter[])

Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.

ExecuteAsync<TElement>(Uri)

Asynchronously sends the request so that this call does not block processing while waiting for the results from the service.

ExecuteBatch(DataServiceRequest[])

Synchronously submits a group of queries as a batch to the data service.

ExecuteBatch(SaveChangesOptions, DataServiceRequest[])

Synchronously submits a group of queries as a batch to the data service.

ExecuteBatchAsync(CancellationToken, DataServiceRequest[])

Asynchronously submits a group of queries as a batch to the data service.

ExecuteBatchAsync(DataServiceRequest[])

Asynchronously submits a group of queries as a batch to the data service.

ExecuteBatchAsync(SaveChangesOptions, CancellationToken, DataServiceRequest[])

Asynchronously submits a group of queries as a batch to the data service.

ExecuteBatchAsync(SaveChangesOptions, DataServiceRequest[])

Asynchronously submits a group of queries as a batch to the data service.

GetEntityDescriptor(Object)

Gets the EntityDescriptor for the supplied entity object.

GetLinkDescriptor(Object, String, Object)

Gets the LinkDescriptor for a specific link that defines the relationship between two entities.

GetMetadataUri()

Gets a URI of the location of .edmx metadata.

GetReadStream(Object, DataServiceRequestArgs)

Gets binary data stream for the specified entity by using the specified message headers.

GetReadStream(Object, String, DataServiceRequestArgs)

Gets a named binary data stream that belongs to the specified entity, by using the specified Content-Type message header.

GetReadStream(Object, String)

Gets the binary data stream that belongs to the specified entity, by using the specified Content-Type message header.

GetReadStream(Object)

Gets the binary data stream that belongs to the specified entity.

GetReadStreamAsync(Object, DataServiceRequestArgs, CancellationToken)

Asynchronously gets the binary data stream that belongs to the specified entity, by using the specified message headers.

GetReadStreamAsync(Object, DataServiceRequestArgs)

Asynchronously gets the binary data stream that belongs to the specified entity, by using the specified message headers.

GetReadStreamAsync(Object, String, DataServiceRequestArgs, CancellationToken)

Asynchronously gets the binary data stream that belongs to the specified entity, by using the specified message headers.

GetReadStreamAsync(Object, String, DataServiceRequestArgs)

Asynchronously gets the binary data stream that belongs to the specified entity, by using the specified message headers.

GetReadStreamUri(Object, String)

Gets the URI that is used to return a named binary data stream.

GetReadStreamUri(Object)

Gets the URI that is used to return a binary data stream.

LoadProperty(Object, String, DataServiceQueryContinuation)

Loads the next page of related entities from the data service by using the supplied query continuation object.

LoadProperty(Object, String, Uri)

Loads a page of related entities by using the supplied next link URI.

LoadProperty(Object, String)

Loads deferred content for a specified property from the data service.

LoadProperty<T>(Object, String, DataServiceQueryContinuation<T>)

Loads the next page of related entities from the data service by using the supplied generic query continuation object.

LoadPropertyAsync(Object, String, CancellationToken)

Asynchronously loads the value of the specified property from the data service.

LoadPropertyAsync(Object, String, DataServiceQueryContinuation, CancellationToken)

Asynchronously loads the next page of related entities from the data service by using the supplied query continuation object.

LoadPropertyAsync(Object, String, DataServiceQueryContinuation)

Asynchronously loads the next page of related entities from the data service by using the supplied query continuation object.

LoadPropertyAsync(Object, String, Uri, CancellationToken)

Asynchronously loads a page of related entities from the data service by using the supplied next link URI.

LoadPropertyAsync(Object, String, Uri)

Asynchronously loads a page of related entities from the data service by using the supplied next link URI.

LoadPropertyAsync(Object, String)

Asynchronously loads the value of the specified property from the data service.

SaveChanges()

Saves the changes that the DataServiceContext is tracking to storage.

SaveChanges(SaveChangesOptions)

Saves the changes that the DataServiceContext is tracking to storage.

SaveChangesAsync()

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

SaveChangesAsync(CancellationToken)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

SaveChangesAsync(SaveChangesOptions, CancellationToken)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

SaveChangesAsync(SaveChangesOptions)

Asynchronously submits the pending changes to the data service collected by the DataServiceContext since the last time changes were saved.

SetLink(Object, String, Object)

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.

SetSaveStream(Object, Stream, Boolean, DataServiceRequestArgs)

Sets a binary data stream for the specified entity, with the specified headers in the request message.

SetSaveStream(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.

SetSaveStream(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.

SetSaveStream(Object, String, Stream, Boolean, String)

Sets a binary data stream for the specified entity.

TryGetAnnotation<TFunc,TResult>(Expression<TFunc>, String, String, TResult)

Try to get instance annotations or metadata annotation for property or navigation property. Or try to get metadata annotation for property, navigation property, entitySet, singleton, operation or operation import.

TryGetAnnotation<TFunc,TResult>(Expression<TFunc>, String, TResult)

Try to get instance annotations or metadata annotation for property or navigation property. Or try to get metadata annotation for property, navigation property, entitySet, singleton, operation or operation import.

TryGetAnnotation<TResult>(Object, String, String, TResult)

Try to get instance annotations or metadata annotation associated with the specified object.

TryGetAnnotation<TResult>(Object, String, TResult)

Try to get instance annotations or metadata annotation associated with the specified object.

TryGetEntity<TEntity>(Uri, TEntity)

Test retrieval of an entity being tracked by the DataServiceContext by reference to the URI of the entity.

TryGetUri(Object, Uri)

Retrieves the canonical URI associated with the specified entity, if available.

UpdateObject(Object, Object[])

Changes the state of the specified object in the DataServiceContext to Modified.

UpdateObject(Object)

Changes the state of the specified object in the DataServiceContext to Modified.

UpdateRelatedObject(Object, String, Object)

Update a related object to the context.

Events

BuildingRequest

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

ReceivingResponse

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

SendingRequest2

This event is fired before a request is sent to the server, giving the handler the opportunity to inspect, adjust and/or replace the WebRequest object used to perform the request.

Applies to