This attribute on an entity type is used to specify the properties that determine changes in content.
<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:
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.
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).
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> { …}
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003