I want to do this in order to have a predefined list of properties to update that I can add onto. For instance, when i want to update a property of some entities, i want to update the specific property AND a predefined list of audit properties (like a datetime column called UpdatedOn)
So, for example, I want to make updates to entities using the following code:
currentContext.myEntities
.Where( some logic )
.ExecuteUpdate(e => myFunction(e)
.SetProperty( additional set property statements));
where an example of the function is something like:
public static Microsoft.EntityFrameworkCore.Query.SetPropertyCalls<T> myFunction<T>(Microsoft.EntityFrameworkCore.Query.SetPropertyCalls<T> call,DateTime timestamp)
where T:AuditableEntity
{
//return a setPropertyCall with one or more SetProperty statements attached
return call.SetProperty(e => e.UpdatedOn, e=>timestamp);
}
Is this possible, is there something im missing? When i try this, i get an error at runtime that says ExecuteUpdate can only have setProperty calls inside it (which i assume means i can't have that function i list above)
If Function might not be the right approach, is there a way to programmatically create a SetPropertyCalls chain?
For Specificity, i get the error:
could not be translated. Additional information: The 'setPropertyCalls' argument to 'ExecuteUpdate' may only contain a chain of 'SetProperty' expressing the properties to be updated.