DevForce Help Reference
IConcurrencyStrategy Interface
Members  Example 


Interface to be implemented when a concurrency strategy of ServerCallback is specified for a property of an entity.
Syntax
'Declaration
 
<InterfaceExportAttribute(ContractName="", ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)>
Public Interface IConcurrencyStrategy 
'Usage
 
Dim instance As IConcurrencyStrategy
[InterfaceExport(ContractName="", ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)]
public interface IConcurrencyStrategy 
Remarks
The IConcurrencyStrategy is needed on the server only.
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;
  }
}
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

IConcurrencyStrategy Members
IdeaBlade.EntityModel Namespace
DefaultConcurrencyValueSetter Class

Send Feedback