.NET Framework Class Library
ETagAttribute Class

This attribute on an entity type is used to specify the properties that determine changes in content.

Namespace:  System.Data.Services
Assembly:  System.Data.Services (in System.Data.Services.dll)
Syntax

Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False, Inherited := True)> _
Public NotInheritable Class ETagAttribute _
    Inherits Attribute
Visual Basic (Usage)
Dim instance As ETagAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class ETagAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false, Inherited = true)]
public ref class ETagAttribute sealed : public Attribute
JScript
public final class ETagAttribute extends Attribute
Remarks

Optimistic concurrency checks are enabled on a per Entity Type basis in ADO.NET Data Services. To enable concurrency checks for a given entity, implement the following requirements:

Common Requirements

If-[None-]Match requests that include a list of eTags are not supported. If an If-[None-]Match header with a list of eTags is provided, the request fails with a 400 Bad Request response.

Services Using Entity Data Model as the Data Provider

Add ConcurrencyMode = Fixed to each property on an entity type definition in the conceptual schema definition language (CSDL) document that is to be part of the types concurrency token.

Further details about eTags can be found in RFC 2616 and the topic Optimistic Concurrency (ADO.NET Data Services Framework).

Services using the CLR (reflection) Data Provider:

Add the ETagAttribute to each of the types representing entity types for which optimistic concurrency checks are enabled.

An ArgumentException is thrown if a key property or reference property (Orders in the example below) is specified as part of the eTag.

Examples

The following example shows a Customer entity type with a concurrency token made up of the value of the CompanyName and Version property.

<EntityType Name="Customer">
    <Key>
      <PropertyRef Name="CustomerID" />
    </Key>
    <Property Name="CustomerID" Type="Int32" Nullable="false"/>
    <Property Name="CompanyName" Type="String" Nullable="false" 
              MaxLength="40" ConcurrencyMode="fixed" />
    <Property Name="Phone" Type="String" MaxLength="24" />
    <Property Name="Version" Type="Int32" Nullable="false" 
              ConcurrencyMode="fixed" />
    <NavigationProperty Name="Orders" Relationship="Northwind.FK_Orders_Customers" 
                        FromRole="Shippers" ToRole="Orders" />
 </EntityType>

The following example shows a common language runtime (CLR) Customer type with a concurrency token made up of the value of the CompanyName and Version property.

[ETag ("CompanyName", "Version", …) ]
public class Customer {
   public int ID { get; set;}
   public string CompanyName {get; set;}
   public int Version {get; set;}
   public IEnumerable<Order> Orders {get{…}; set{…}}
}

//Order class

public class MyData
{
    public IQueryable<Customer> Customers{  get{…} }
    public IQueryable<Order> Orders{  get{…} }
}

public class MyDataService : DataService<MyData> 
{ …}

Inheritance Hierarchy

System..::.Object
  System..::.Attribute
    System.Data.Services..::.ETagAttribute
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.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5 SP1
See Also

Reference

Tags :


Page view tracker