Hi, I'm trying to add a custom method to all my repositories. So in the baserepository code I added this:
public abstract class AppRepositoryBase<TEntity, TPrimaryKey> : EfCoreRepositoryBase<AppDbContext, TEntity, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey>
{
protected AppRepositoryBase(IDbContextProvider<AppDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
//add your common methods for all repositories
public async Task BulkInsert(List<TEntity> entities)
{
await Context.BulkInsertAsync(entities);
}
}
That is ok, but when trying to use it in a repository : IRepository<classname, long> the method is not available.
Am I missing something?
4 Answer(s)
-
0
Hi @robrechtbelien
Instead of adding this method to your base repository class, add it as an extension method to IRepository interface.
-
0
Hi @ismcagdas,
Can you point me in the right direction? Is the IRepository part of the ABP framework or is it in the aspnetzero code?
-
0
Additionally: When using the bulkinsert method, the entityhelper function are not run, is it possible to extend them to intercept the bulkinsert function somehow?
-
0
I mean something like this https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/Domain/Repositories/RepositoryExtensions.cs#L105
Which library are you using for BulInsert ? I think it saves records in an unusual way and EF Core's savechanges can't see the changes in entities.