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.
Inheritance Hierarchy
System.Object
System.Attribute
System.ComponentModel.DataAnnotations.RoundtripOriginalAttribute
Namespace: System.ComponentModel.DataAnnotations
Assembly: System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple := False)> _
Public NotInheritable Class RoundtripOriginalAttribute _
Inherits Attribute
'Usage
Dim instance As RoundtripOriginalAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false)]
public sealed class RoundtripOriginalAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Property|AttributeTargets::Field, AllowMultiple = false)]
public ref class RoundtripOriginalAttribute sealed : public Attribute
[<SealedAttribute>]
[<AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false)>]
type RoundtripOriginalAttribute =
class
inherit Attribute
end
public final class RoundtripOriginalAttribute extends Attribute
The RoundtripOriginalAttribute type exposes the following members.
Constructors
Name | Description | |
---|---|---|
RoundtripOriginalAttribute | Initializes a new instance of the RoundtripOriginalAttribute class. |
Top
Properties
Name | Description | |
---|---|---|
TypeId | (Inherited from Attribute.) |
Top
Methods
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.) |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
_Attribute.GetIDsOfNames | (Inherited from Attribute.) | |
_Attribute.GetTypeInfo | (Inherited from Attribute.) | |
_Attribute.GetTypeInfoCount | (Inherited from Attribute.) | |
_Attribute.Invoke | (Inherited from Attribute.) |
Top
Remarks
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 nulla null reference (Nothing in Visual Basic) 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.
Examples
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
[MetadataTypeAttribute(typeof(Address.AddressMetadata))]
public partial class Address
{
internal sealed class AddressMetadata
{
// Metadata classes are not meant to be instantiated.
private AddressMetadata()
{
}
public int AddressID;
[Required]
[StringLength(60)]
public string AddressLine1;
public string AddressLine2;
[Required]
[StringLength(30)]
public string City;
public string CountryRegion;
public EntityCollection<CustomerAddress> CustomerAddresses;
public DateTime ModifiedDate;
[Required]
public string PostalCode;
[Exclude]
public Guid rowguid;
public string StateProvince;
}
}
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.