IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace : IConcurrencyStrategy Interface |
'Declaration
<InterfaceExportAttribute(ContractName="", ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)> Public Interface IConcurrencyStrategy
'Usage
Dim instance As IConcurrencyStrategy
[InterfaceExport(ContractName="", ContractType=IdeaBlade.EntityModel.IConcurrencyStrategy)] public interface IConcurrencyStrategy
// 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; } }
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