ABP 自定义仓储 Target does not implement interface IRepository

.Net技术 码拜 5年前 (2019-08-19) 2054次浏览 0个评论

ABP实现的默认仓储已经足够大多场景的使用,个别场景还是需要创建自定义仓储。按照文档介绍方式实现过程中,出现了错误:

Target does not implement interface Abp.Domain.Repositories.IRepository`1[[Abp.Localization.ApplicationLanguage, Abp.Zero.Common, Version=4.8.1.0, Culture=neutral, PublicKeyToken=null]]
参数名: target
以下是修改后的代码:BatchInsertTestRepository<TEntity> 需要继承接口IRepository<TEntity>
    
    public class BatchInsertTestRepository<TEntity, TPrimaryKey> : BatchInsertTestRepositoryBase<TEntity, TPrimaryKey>
  where TEntity : class, IEntity<TPrimaryKey>
    {
        public BatchInsertTestRepository(IDbContextProvider<BatchInsertTestDbContext> dbContextProvider)
 : base(dbContextProvider)
        {

        }
    }

    public class BatchInsertTestRepository<TEntity> : BatchInsertTestRepository<TEntity, int>, <span style="color: #ff00ff;"><a href="https://www.codebye.com/tag/irepository" title="查看更多关于IRepository的文章" target="_blank">IRepository</a><TEntity></span> where TEntity : class, IEntity<int>
    {
        public BatchInsertTestRepository(IDbContextProvider<BatchInsertTestDbContext> dbContextProvider)
 : base(dbContextProvider)
        {

        }
    }

DbContext的部分实现:

[AutoRepositoryTypes(
typeof(<a href="https://www.codebye.com/tag/irepository" title="查看更多关于IRepository的文章" target="_blank">IRepository</a><>),
typeof(<a href="https://www.codebye.com/tag/irepository" title="查看更多关于IRepository的文章" target="_blank">IRepository</a><,>),
typeof(BatchInsertTestRepository<>),
typeof(BatchInsertTestRepository<,>)
)]
public class BatchInsertTestDbContext : AbpZeroDbContext<Tenant, Role, User>
{ ... }

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明ABP 自定义仓储 Target does not implement interface IRepository
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!