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 | |
---|---|---|
![]() |
Entity | Initializes a new instance of the Entity class. |
Top
Properties
Name | Description | |
---|---|---|
![]() |
EntityActions | Gets the list of custom method invocations pending for this entity. |
![]() |
EntityConflict | Gets conflict information for this entity after a submit operation. |
![]() |
EntitySet | Gets the EntitySet that this Entity is a member of. |
![]() |
EntityState | Gets the current state of this Entity. |
![]() |
HasChanges | Gets a value indicating whether this entity currently has any pending changes |
![]() |
HasValidationErrors | Gets a value indicating whether this entity has any validation errors. |
![]() |
IsDeserializing | Gets a value indicating whether the current entity is currently being deserialized. |
![]() |
IsReadOnly | Gets a value indicating whether this entity is currently in a read-only state. |
![]() |
ValidationErrors | Gets the collection of validation errors for this entity. |
Top
Methods
Name | Description | |
---|---|---|
![]() |
AcceptChanges | Accepts the current changes to this Entity and applies the appropriate state transitions. |
![]() |
BeginEdit | Begins editing the Entity. |
![]() |
CancelEdit | Cancels any edits made to the Entity since the last call to BeginEdit. |
![]() |
CanInvokeAction | Gets a value indicating whether the specified action can currently be invoked. |
![]() |
EndEdit | Commits the edits made to this entity since the last call to EndEdit. |
![]() |
Equals | (Inherited from Object.) |
![]() |
Finalize | (Inherited from Object.) |
![]() |
GetHashCode | (Inherited from Object.) |
![]() |
GetIdentity | Returns the entity identity, suitable for hashing. |
![]() |
GetOriginal | Gets the original state for this entity. |
![]() |
GetType | (Inherited from Object.) |
![]() |
InvokeAction | Called to register an action to be invoked for this entity when submitting changes. |
![]() |
IsActionInvoked | Indicates whether the specified action has been invoked. |
![]() |
MemberwiseClone | (Inherited from Object.) |
![]() |
OnActionStateChanged | Called when the invoked action state changes for this entity. |
![]() |
OnDeserialized | Called after this Entity has been deserialized. |
![]() |
OnDeserializing | Called when this Entity is being deserialized. |
![]() |
OnLoaded | Called when an Entity is loaded into an EntitySet. |
![]() |
OnPropertyChanged | Called when an Entity property has changed. |
![]() |
RaiseDataMemberChanged | Called from a property setter to notify the framework that an Entity data member has changed. |
![]() |
RaiseDataMemberChanging | Called from a property setter to notify the framework that an Entity data member is about to be changed. |
![]() |
RaisePropertyChanged | Called from a property setter to notify the framework that an Entity member has changed. |
![]() |
RejectChanges | Reverts all property changes made to this entity back to their original values. |
![]() |
ToString | Gets a string representation of the current entity. (Overrides Object.ToString().) |
![]() |
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. |
![]() |
ValidateProperty(ValidationContext, Object) | Indicates whether the specified property value is valid for the specified validation context. |
![]() |
ValidateProperty(String, Object) | Indicates whether the specified value is valid for the specified property of the current entity. |
Top
Events
Name | Description | |
---|---|---|
![]() |
PropertyChanged | Occurs when an Entity property has changed. |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
![]() ![]() |
IChangeTracking.AcceptChanges | Accepts all changes made to this entity. |
![]() ![]() |
IEditableObject.BeginEdit | Begins editing this entity. |
![]() ![]() |
IEditableObject.CancelEdit | Cancels the edits made to this entity since the last call to BeginEdit. |
![]() ![]() |
IEditableObject.EndEdit | Commits the edits made to this entity since the last call to BeginEdit. |
![]() ![]() |
INotifyDataErrorInfoErrorsChanged | Occurs when the validation errors have changed for a property or for the entire entity. |
![]() ![]() |
INotifyDataErrorInfoGetErrors | Gets the validation errors for a specified property or for the entire entity. |
![]() ![]() |
INotifyDataErrorInfoHasErrors | Gets a value that indicates whether the entity has validation errors. |
![]() ![]() |
IChangeTracking.IsChanged | Gets a value indicating whether this entity currently has any pending changes. |
![]() ![]() |
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.