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

.Net技术 码拜 6年前 (2019-08-19) 2190次浏览 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>
  1. public class BatchInsertTestRepository<TEntity, TPrimaryKey> : BatchInsertTestRepositoryBase<TEntity, TPrimaryKey>
  2. where TEntity : class, IEntity<TPrimaryKey>
  3. {
  4. public BatchInsertTestRepository(IDbContextProvider<BatchInsertTestDbContext> dbContextProvider)
  5. : base(dbContextProvider)
  6. {
  7.  
  8. }
  9. }
  10.  
  11. 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>
  12. {
  13. public BatchInsertTestRepository(IDbContextProvider<BatchInsertTestDbContext> dbContextProvider)
  14. : base(dbContextProvider)
  15. {
  16.  
  17. }
  18. }

DbContext的部分实现:

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

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

文章评论已关闭!