I have the following interface signature that I want to use for a more efficient bulk update using EF Core 8.0.6
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
using System.Linq.Expressions;
namespace IRepositories
{
Task<int> UpdateDirectAsync(Expression<Func<T, bool>> filter,
Func<SetPropertyCalls<T>,
SetPropertyCalls<T>> setPropertyCalls);
}
}
But I am getting the following error:
The type or namespace name 'SetPropertyCalls<>' could not be found (are you missing a using directive or an assembly reference?)
How can I resolve this?
Microsoft.EntityFrameworkCore.Relationalpackage is referenced.public interface ISomethingOrAnother......in your code .....DbContextis already a respository? Just doawait myDb.SomeTable.Where(whatever).ExecuteUpdateAsync(x => x.SetProperty(whateverwhat does your generic method offer thatExecuteUpdateAsyncdoes not?Expression<Func<T>>andFunc<T>declarations to cater to differences in consumer needs. A Repository can standardize common behavior by leveragingIQueryable<T>. You are trying to scratch an itch at the thought of writing similar, dead simple query statements multiple times, but replacing it with writing one complex beast that still needs multiple complex parameters.