quentinjs wrote:
I have the following but it blows up on Fields property on the CommonEntityBase.
IEntityField lastModifiedDateField = entity.Fields(entity.ConcurrencyCheckFieldName);
Use this (array enumeration):
IEntityField lastModifiedDateField = entity.Fields[entity.ConcurrencyCheckFieldName];
Additional comment. I think this:
toReturn.Add(new FieldCompareValuePredicate(lastModifiedDateField, ComparisonOperator.Equal, lastModifiedDateField.CurrentValue));
should be
toReturn.Add(new FieldCompareValuePredicate(lastModifiedDateField, ComparisonOperator.Equal, lastModifiedDateField.DBValue));
(quoted from docs):
To filter on the original database values fetched into the entity to be saved, you can create for example FieldCompareValuePredicate instances which use the EntityField2's DbValue property. Even though a field is changed in memory through code, the DbValue property of a field will have the original value read from the database. You can use this for optimistic concurrency schemes.