Export (0) Print
Expand All

RoundtripOriginalAttribute Class

WCF RIA Services

[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.

System.Object
  System.Attribute
    System.ComponentModel.DataAnnotations.RoundtripOriginalAttribute

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

[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false)]
public sealed class RoundtripOriginalAttribute : Attribute

The RoundtripOriginalAttribute type exposes the following members.

  NameDescription
Public methodRoundtripOriginalAttributeInitializes a new instance of the RoundtripOriginalAttribute class.
Top

  NameDescription
Public propertyTypeId (Inherited from Attribute.)
Top

  NameDescription
Public methodEquals (Inherited from Attribute.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Attribute.)
Public methodGetType (Inherited from Object.)
Public methodIsDefaultAttribute (Inherited from Attribute.)
Public methodMatch (Inherited from Attribute.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate method_Attribute.GetIDsOfNames (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfo (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoCount (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.Invoke (Inherited from Attribute.)
Top

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 null 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(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;
    }
}


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft