DomainContext Class
[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]
A DomainContext is a stateful client-side representation of a domain service, providing access to all the functionality of the service.
System.ServiceModel.DomainServices.Client.DomainContext
System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationDomainContextBase
Namespace: System.ServiceModel.DomainServices.Client
Assembly: System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)
The DomainContext type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | DomainClient | Gets the DomainClient for this context. |
![]() | EntityContainer | Gets the EntityContainer holding all entities loaded by this context. |
![]() | HasChanges | Gets a value indicating whether this context has any pending changes. |
![]() | IsLoading | Gets a value indicating whether this DomainContext is currently performing a load operation. |
![]() | IsSubmitting | Gets a value indicating whether this DomainContext is currently performing a submit operation. |
![]() | ValidationContext | Gets or sets the Silverlight ValidationContext to use for all validation operations invoked by the DomainContext. |
| Name | Description | |
|---|---|---|
![]() | AddReference | Adds a reference to an external DomainContext. |
![]() | CreateEntityContainer | Creates and returns an entity container configured with EntitySet objects for all entities this DomainContext will provide access to. |
![]() | CreateQuery(Of TEntity) | Creates an EntityQuery. |
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | (Inherited from Object.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | InvokeOperation(String, Type, IDictionary(Of String, Object), Boolean, Action(Of InvokeOperation), Object) | Executes an invoke operation. |
![]() | InvokeOperation(Of TValue)(String, Type, IDictionary(Of String, Object), Boolean, Action(Of InvokeOperation(Of TValue)), Object) | Executes an invoke operation. |
![]() | Load(EntityQuery, LoadBehavior, Action(Of LoadOperation), Object) | Initiates a load operation for the specified query with the specified load behavior, callback method, and user state. |
![]() | Load(Of TEntity)(EntityQuery(Of TEntity)) | Initiates a load operation for the specified query. |
![]() | Load(Of TEntity)(EntityQuery(Of TEntity), Boolean) | Initiates a load operation for the specified query with the specified value indicating whether an error results in an exception. |
![]() | Load(Of TEntity)(EntityQuery(Of TEntity), Action(Of LoadOperation(Of TEntity)), Object) | Initiates a load operation for the specified query with the specified callback method, and user state. |
![]() | Load(Of TEntity)(EntityQuery(Of TEntity), LoadBehavior, Boolean) | Initiates a load operation for the specified query with the specified load behavior, and value indicating whether an error results in an exception. |
![]() | Load(Of TEntity)(EntityQuery(Of TEntity), LoadBehavior, Action(Of LoadOperation(Of TEntity)), Object) | Initiates a load operation for the specified query with the specified load behavior, callback method, and user state. |
![]() | MemberwiseClone | (Inherited from Object.) |
![]() | RaisePropertyChanged | Raises the PropertyChanged event for the specified property. |
![]() | RejectChanges | Reverts all pending changes for this DomainContext. |
![]() | SubmitChanges | Submits all pending changes to the domain service. |
![]() | SubmitChanges(Action(Of SubmitOperation), Object) | Submits all pending changes to the domain service. |
![]() | ToString | (Inherited from Object.) |
![]() | ValidateMethod | Validates a method call. |
For each domain service in the server project, WCF RIA Services generates a class that derives from DomainContext. You use the generated DomainContext class to interact with the domain service. You retrieve data by calling the Load method and passing one of the generated query methods as a parameter. You save changes in the data by calling the SubmitChanges method. You cancel all pending data changes and revert the data to its previous state by calling the RejectChanges method. The generated class contains query methods that correspond to query methods in the domain service. By default, RIA Services uses a naming convention for the generated domain context and its methods. For example, a domain service in the server project named CustomerDomainService will have a domain context class in the client project named CustomerDomainContext. A query method named GetCustomers has a corresponding method in the client project named GetCustomersQuery. For more information, see Client Code Generation.
To find the generated domain context class, select Show All Files in the Silverlight project and open the Generated_Code folder.
When you execute a domain operation, the operation is processed asynchronously. To take an action after the operation has completed, you must provide a callback method. An example of providing a callback method is shown below.
The following example shows how to create an instance of a generated DomainContext class and load data from a query.
Imports System.Windows.Ria Imports RIAServicesExample.Web Partial Public Class MainPage Inherits UserControl Private _customerContext As New CustomerDomainContext Public Sub New() InitializeComponent() Dim loadOp = Me._customerContext.Load(Me._customerContext.GetCustomersQuery()) CustomerGrid.ItemsSource = loadOp.Entities End Sub End Class
