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)
Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False, Inherited := True)> _
Public NotInheritable Class ETagAttribute _
Inherits Attribute
Dim instance As ETagAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class ETagAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false, Inherited = true)]
public ref class ETagAttribute sealed : public Attribute
public final class ETagAttribute extends Attribute
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
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.
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>
{ …}
System..::.Object
System..::.Attribute
System.Data.Services..::.ETagAttribute
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
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.
.NET Framework
Supported in: 3.5 SP1
Reference