RoundtripOriginalAttribute 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.]
When applied to a member, this attribute indicates that the original value of the member should be sent back to the server when the object is updated. When applied to a class, the attribute gets applied to each member of that class.
Namespace: System.ComponentModel.DataAnnotations
Assembly: System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)
The RoundtripOriginalAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | RoundtripOriginalAttribute | Initializes a new instance of the RoundtripOriginalAttribute class. |
| Name | Description | |
|---|---|---|
![]() | Equals | (Inherited from Attribute.) |
![]() | Finalize | (Inherited from Object.) |
![]() | GetHashCode | (Inherited from Attribute.) |
![]() | GetType | (Inherited from Object.) |
![]() | IsDefaultAttribute | (Inherited from Attribute.) |
![]() | Match | (Inherited from Attribute.) |
![]() | MemberwiseClone | (Inherited from Object.) |
![]() | ToString | (Inherited from Object.) |
You apply the RoundtripOriginalAttribute attribute to a property in an entity when you want to send the value of that property to the server to ensure data concurrency. If this attribute is not present, the value of this member will be Nothing in the original object sent back to the server.
When you enable users to update or delete data, make sure that the data in the data source has not been changed by another process before you continue with the update or delete. If you do not check whether the values have changed, you can unintentionally overwrite values set by another process.
By default, RIA Services does not pass the entire original entity along with the changed values to the data access layer to check for data concurrency. Instead, RIA Services stores and passes back only those members that are marked with the RoundtripOriginalAttribute attribute, the ConcurrencyCheckAttribute attribute, or the TimestampAttribute attribute. These concurrency attributes can be applied to the metadata classes when working with the Entity Framework or directly to CLR objects when working with POCO-defined data models. This implementation enables you to optimize the performance of your application by specifying only those members that you want to participate in the concurrency check.
The following example shows an address metadata class with RoundtripOriginalAttribute, RequiredAttribute, StringLengthAttribute, and ExcludeAttribute variously applied to its properties.
<MetadataTypeAttribute(GetType(Address.AddressMetadata))> _ Partial Public Class Address Friend NotInheritable Class AddressMetadata 'Metadata classes are not meant to be instantiated. Private Sub New() MyBase.New End Sub Public AddressID As Integer <Required()> _ <StringLength(60)> _ Public AddressLine1 As String Public AddressLine2 As String <Required()> _ <StringLength(30)> _ Public City As String Public CountryRegion As String Public CustomerAddresses As EntityCollection(Of CustomerAddress) Public ModifiedDate As DateTime <Required()> _ Public PostalCode As String <Exclude()> _ Public rowguid As Guid Public StateProvince As String End Class End Class
