Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
ETagAttribute Class
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.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)
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

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.

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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker