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



Interface to be implemented when a concurrency strategy of ServerCallback is specified for a property of an entity.

Syntax

Visual Basic (Declaration) 
<InterfaceExportAttribute(ContractName="", ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)>
Public Interface IConcurrencyStrategy 
Visual Basic (Usage)Copy Code
Dim instance As IConcurrencyStrategy
C# 
[InterfaceExportAttribute(ContractName="", ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)]
public interface IConcurrencyStrategy 
C++/CLI 
[InterfaceExportAttribute(ContractName="", ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)]
public interface class 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 IConcurrencyStrategy is needed on the server only.

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.