Entity 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.]

Base class for all entity types.

Inheritance Hierarchy

System.Object
  System.ServiceModel.DomainServices.Client.Entity

Namespace:  System.ServiceModel.DomainServices.Client
Assembly:  System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

Syntax

'Declaration
<DataContractAttribute> _
Public MustInherit Class Entity _
    Implements INotifyDataErrorInfo, IEditableObject, INotifyPropertyChanged, IRevertibleChangeTracking,  _
    IChangeTracking
'Usage
Dim instance As Entity
[DataContractAttribute]
public abstract class Entity : INotifyDataErrorInfo, 
    IEditableObject, INotifyPropertyChanged, IRevertibleChangeTracking, IChangeTracking
[DataContractAttribute]
public ref class Entity abstract : INotifyDataErrorInfo, 
    IEditableObject, INotifyPropertyChanged, IRevertibleChangeTracking, IChangeTracking
[<AbstractClassAttribute>]
[<DataContractAttribute>]
type Entity =  
    class
        interface INotifyDataErrorInfo
        interface IEditableObject
        interface INotifyPropertyChanged
        interface IRevertibleChangeTracking
        interface IChangeTracking
    end
public abstract class Entity implements INotifyDataErrorInfo, IEditableObject, INotifyPropertyChanged, IRevertibleChangeTracking, IChangeTracking

The Entity type exposes the following members.

Constructors

  Name Description
Protected method Entity Initializes a new instance of the Entity class.

Top

Properties

  Name Description
Public property EntityActions Gets the list of custom method invocations pending for this entity.
Public property EntityConflict Gets conflict information for this entity after a submit operation.
Protected property EntitySet Gets the EntitySet that this Entity is a member of.
Public property EntityState Gets the current state of this Entity.
Public property HasChanges Gets a value indicating whether this entity currently has any pending changes
Public property HasValidationErrors Gets a value indicating whether this entity has any validation errors.
Protected property IsDeserializing Gets a value indicating whether the current entity is currently being deserialized.
Public property IsReadOnly Gets a value indicating whether this entity is currently in a read-only state.
Public property ValidationErrors Gets the collection of validation errors for this entity.

Top

Methods

  Name Description
Protected method AcceptChanges Accepts the current changes to this Entity and applies the appropriate state transitions.
Protected method BeginEdit Begins editing the Entity.
Protected method CancelEdit Cancels any edits made to the Entity since the last call to BeginEdit.
Protected method CanInvokeAction Gets a value indicating whether the specified action can currently be invoked.
Protected method EndEdit Commits the edits made to this entity since the last call to EndEdit.
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetIdentity Returns the entity identity, suitable for hashing.
Public method GetOriginal Gets the original state for this entity.
Public method GetType (Inherited from Object.)
Protected method InvokeAction Called to register an action to be invoked for this entity when submitting changes.
Protected method IsActionInvoked Indicates whether the specified action has been invoked.
Protected method MemberwiseClone (Inherited from Object.)
Protected method OnActionStateChanged Called when the invoked action state changes for this entity.
Public method OnDeserialized Called after this Entity has been deserialized.
Public method OnDeserializing Called when this Entity is being deserialized.
Protected method OnLoaded Called when an Entity is loaded into an EntitySet.
Protected method OnPropertyChanged Called when an Entity property has changed.
Protected method RaiseDataMemberChanged Called from a property setter to notify the framework that an Entity data member has changed.
Protected method RaiseDataMemberChanging Called from a property setter to notify the framework that an Entity data member is about to be changed.
Protected method RaisePropertyChanged Called from a property setter to notify the framework that an Entity member has changed.
Protected method RejectChanges Reverts all property changes made to this entity back to their original values.
Public method ToString Gets a string representation of the current entity. (Overrides Object.ToString().)
Protected method UpdateActionState Called within the context of an OnActionStateChanged override. This method will raise the appropriate property changed notifications for the properties corresponding to a custom method.
Protected method ValidateProperty(ValidationContext, Object) Indicates whether the specified property value is valid for the specified validation context.
Protected method ValidateProperty(String, Object) Indicates whether the specified value is valid for the specified property of the current entity.

Top

Events

  Name Description
Public event PropertyChanged Occurs when an Entity property has changed.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IChangeTracking.AcceptChanges Accepts all changes made to this entity.
Explicit interface implemetationPrivate method IEditableObject.BeginEdit Begins editing this entity.
Explicit interface implemetationPrivate method IEditableObject.CancelEdit Cancels the edits made to this entity since the last call to BeginEdit.
Explicit interface implemetationPrivate method IEditableObject.EndEdit Commits the edits made to this entity since the last call to BeginEdit.
Explicit interface implemetationPrivate event INotifyDataErrorInfoErrorsChanged Occurs when the validation errors have changed for a property or for the entire entity.
Explicit interface implemetationPrivate method INotifyDataErrorInfoGetErrors Gets the validation errors for a specified property or for the entire entity.
Explicit interface implemetationPrivate property INotifyDataErrorInfoHasErrors Gets a value that indicates whether the entity has validation errors.
Explicit interface implemetationPrivate property IChangeTracking.IsChanged Gets a value indicating whether this entity currently has any pending changes.
Explicit interface implemetationPrivate method IRevertibleChangeTracking.RejectChanges Rejects all changes made to this entity.

Top

Remarks

When you expose an entity on the server through a query operation, a corresponding entity is generated in the client project. The generated entity derives from the Entity class and contains the same properties as the entity class in the server project. Any validation attributes that you apply to the entity on the server will also be applied to the client entity. The generated client entity contains partial methods, such as OnFirstNameChanging where FirstName is the name of a property in the entity. You can implement the partial methods to provide customized code that is executed during specified events. For more information, see Client Code Generation and Customizing Generated Code.

Examples

The following example shows how to extend a generated entity class by implementing the partial methods to customize a property value.

Imports System.ServiceModel.DomainServices.Client

Namespace Web
  Partial Public Class Employee
    Inherits Entity

    ReadOnly Property TotalOffHours() As Integer
      Get
        Return Me.SickLeaveHours + Me.VacationHours
      End Get
    End Property

    Private Sub OnSickLeaveHoursChanged()
      Me.RaisePropertyChanged("TotalOffHours")
    End Sub

    Private Sub OnVacationHoursChanged()
      Me.RaisePropertyChanged("TotalOffHours")
    End Sub
  End Class
End Namespace
using System.ServiceModel.DomainServices.Client;

namespace RIAServicesExample.Web
{
  public partial class Employee : Entity
  { 
    public int TotalOffHours 
    { 
      get { return this.SickLeaveHours + this.VacationHours; } 
    } 
    partial void OnSickLeaveHoursChanged() 
    { 
      this.RaisePropertyChanged("TotalOffHours"); 
    } 
    partial void OnVacationHoursChanged() 
    { 
      this.RaisePropertyChanged("TotalOffHours"); 
    } 
  }
}

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.

See Also

Reference

System.ServiceModel.DomainServices.Client Namespace