DevForce Help Reference
DefaultConcurrencyValueSetter Class
Members  Example 


Default implementation of the IConcurrencyStrategy interface.
Syntax
'Declaration
 
<DataContractAttribute()>
<DefaultExportAttribute(IsDefault=True, 
   ContractName="", 
   ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)>
Public Class DefaultConcurrencyValueSetter 
   Implements IConcurrencyStrategy 
'Usage
 
Dim instance As DefaultConcurrencyValueSetter
[DataContract()]
[DefaultExport(IsDefault=true, 
   ContractName="", 
   ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)]
public class DefaultConcurrencyValueSetter : IConcurrencyStrategy  
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.
Example
// 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 == EntityRowState.Modified) {
      nextval = item.RowVersion.HasValue ? item.RowVersion.Value + 1 : 1;
    }

    item.RowVersion = nextval;
  }
}
Inheritance Hierarchy

System.Object
   IdeaBlade.EntityModel.DefaultConcurrencyValueSetter

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DefaultConcurrencyValueSetter Members
IdeaBlade.EntityModel Namespace
IConcurrencyStrategy Interface

Send Feedback