I've got a custom include template that creates an additional constructor on entities that have a specific field for concurrency control. This has been working fine until it came to working with inherited entities. The problem is that my concurrency field is on the base class table but I still want this behaviour on all derived entities.
Here is the code that I use:
<[If HasEntityField "ROWLOCKKEY"]>
<[If Not StringValueEquals CustomPropertyName "DoNotCreateConcurrencyPredicateFactory"]>
/// <summary> CTor</summary>
/// <param name="iD">PK value for <[CurrentEntityName ]> which data should be fetched into this <[ CurrentEntityName ]> object</param>
/// <param name="rowVersion">Concurrency Control field for this entity. Providing this value will set the underlying DbValue property. Used for updating entities without fetching first</param>
/// <remarks>The entity is not fetched by this constructor. Use a DataAccessAdapter for that.</remarks>
public <[ CurrentEntityName ]>Entity(System.Int32 iD, System.Int32 rowVersion):this(iD)
{
// Assign both the current value and the DbValue of ROWLOCKKEY. This is used to maintain concurrency control when updating entities
// without first fetching that entity.
Fields[(int)<[ CurrentEntityName ]>FieldIndex.ROWLOCKKEY].ForcedCurrentValueWrite(rowVersion, rowVersion);
Fields.AcceptChanges();
IsNew = false;
}
<[EndIf]>
<[EndIf]>
The problem is that "HasEntityField" is not true while processing a subclass entity even though that entity will indeed have this field from its base class.
Can you suggest a way that I can test whether the base entity has the field? I just can't seem to figure out what combination of template elements to use to achieve this.