EntityFramework-Plus icon indicating copy to clipboard operation
EntityFramework-Plus copied to clipboard

BatchUpdate using Generic Types

Open TrplM opened this issue 9 years ago • 5 comments

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
            }));
}

TrplM avatar Oct 24 '17 21:10 TrplM

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

JonathanMagnan avatar Oct 25 '17 14:10 JonathanMagnan

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

JonathanMagnan avatar Nov 04 '17 19:11 JonathanMagnan

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

JonathanMagnan avatar Nov 07 '17 02:11 JonathanMagnan

Perfect thanks.

We'll test this week and provide feedback

TrplM avatar Nov 07 '17 10:11 TrplM

Hi @JonathanMagnan

Can confirm this is working as expected.

Thanks for the quick resolution.

TrplM avatar Nov 15 '17 08:11 TrplM