if (typeof(T).GetInterface(nameof(IHasEntityModifierData)) != null)
{
await _context.Set<T>()
.Where(predicate)
.ExecuteUpdateAsync(a=>a.SetProperty(p=>(p as IHasEntityModifierData).LastModifiedDate,DateTime.UtcNow));
}
Error is:
ExecuteUpdate(a => a.SetProperty<DateTime?>(rn propertyExpression: p => (p as IHasEntityModifierData).LastModifiedDate, rn valueExpression: (DateTime?)DateTime.UtcNow))’ could not be translated. Additional information: The following lambda argument to ‘SetProperty’ does not represent a valid property to be set: ‘p => (p as IHasEntityModifierData).LastModifiedDate’
Suppose I have Client and Product entities
Client implements IHasEntityModifierData, Product not.
To generate execute update via common method I want to update modified date also if entity implements IHasEntityModifierData. But casting in this method is not working
Rustam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.