IdeaBlade DevForce 2010 Help Reference
DefaultConcurrencyValueSetter Class
Members  Example  See Also  Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace : DefaultConcurrencyValueSetter Class



Default implementation of the IConcurrencyStrategy interface.

Syntax

Visual Basic (Declaration) 
<DataContractAttribute()>
<DefaultExportAttribute(IsDefault=True, 
   ContractName="", 
   ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)>
Public Class DefaultConcurrencyValueSetter 
   Implements IConcurrencyStrategy 
Visual Basic (Usage)Copy Code
Dim instance As DefaultConcurrencyValueSetter
C# 
[DataContractAttribute()]
[DefaultExportAttribute(IsDefault=true, 
   ContractName="", 
   ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)]
public class DefaultConcurrencyValueSetter : IConcurrencyStrategy  
C++/CLI 
[DataContractAttribute()]
[DefaultExportAttribute(IsDefault=true, 
   ContractName="", 
   ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)]
public ref class DefaultConcurrencyValueSetter : public IConcurrencyStrategy  

Example

C#Copy Code
// Sample IConcurrencyStrategy implementation.
public class ProduceConcurrencyValueSetter : IConcurrencyStrategy {

  // Return true if this strategy can be used with the data source.
  public bool IsApplicable(IdeaBlade.Core.IDataSourceKey dataSourceKey) {
    return dataSourceKey.Name.StartsWith("Produce");
  }

  // Called during SaveChanges processing when a new value is needed prior to insert/update.
  // In this example, we just increment a RowVersion property by 1. 
  public void SetNewConcurrencyValue(ConcurrencyProperty property, Entity entity) {
    ItemOfProduce item = entity as ItemOfProduce;
    int nextval = 0;
    
    if (item.RowState == DataRowState.Modified) {
      nextval = item.RowVersion.HasValue ? item.RowVersion.Value + 1 : 1;
    }

    item.RowVersion = nextval;
  }
}

Remarks

The DevForce Object Mapper allows you to set a concurrency strategy on one or more properties of every Entity. When you choose a concurrency strategy of ServerCallback you must implement a custom IConcurrencyStrategy, or extend the DefaultConcurrencyValueSetter, in order to provide an updated value for the concurrency property.

Inheritance Hierarchy

System.Object
   IdeaBlade.EntityModel.DefaultConcurrencyValueSetter

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.