BatchUpdate using Generic Types
I am trying to use the BatchUpdate extension with a generic utility method.
However, I keep getting an exception "Invalid Cast. The update expression must be of type MemberInitExpression."
Is it possible to use BatchUpdate extension like this or am I heading down the wrong track?
public Task<int> DeleteAsync<TEntity>(Expression<Func<TEntity, bool>> Filter, bool ForceDelete = false) where TEntity : class, IAuditableEntity
{
if (ForceDelete)
{
//omiited
return ctx.Set<TEntity>().Where(Filter).DeleteAsync();
}
//omiited
return ctx.Set<TEntity>().Where(Filter).UpdateAsync(item => ((TEntity)(IAuditableEntity)new AuditableEntity
{
DeletedAt = DateTime.UtcNow,
IsDeleted = true
}));
}
Hello @TrplM ,
I'm currently a little bit to much busy with other request but I will add it to the list.
We will try to check if we can support your scenario.
Best Regards,
Jonathan
Hello @TrplM ,
Sorry for the delay,
The fix has been completed, it should be released for Monday. I will let you know as soon as this new version is available.
Best Regards,
Jonathan
Hello @TrplM ,
The version 1.7.6 has been released: https://github.com/zzzprojects/EntityFramework-Plus/releases/tag/v1.7.6
Let me know if Batch Update now support correctly Cast
Best Regards,
Jonathan
Perfect thanks.
We'll test this week and provide feedback
Hi @JonathanMagnan
Can confirm this is working as expected.
Thanks for the quick resolution.