I have a pretty large Blazor project where I have some small repositories (for simple entities) that derive from a GenericRepository like
public class MySmallRepositoryOne : GenericRepository<MySmallEntityOne>, IMySmallRepositoryOne
But I also have Repositories for more complex entities that doens't derive from GenericRepository.
Are there a way to make an
public override int SaveChangesAsync()
{
// my code
return base.SaveChangesAsync();
}
that override SaveChangesAsync() for all repositories? Or does every repository need to derive from Generic and it's in generic I put this override?
Yes, you could override "savechanges" in specific "xxxDbContext". But SaveChangesAsync should be written asynchronously to use await. Needn't derive every repository.