abp icon indicating copy to clipboard operation
abp copied to clipboard

Don't understandable recommendation in documentation

Open EugeniZaplatin opened this issue 4 years ago • 2 comments

On this page - https://docs.abp.io/en/abp/5.2/Best-Practices/Repositories I see recomendation: "Do not use generic repository interfaces (like IRepository<IdentityUser, Guid>) from the application code." but in all examples I see usin this generic interface: for example https://docs.abp.io/en/abp/5.2/Application-Services#crud-application-services or in EShopOnAbp.CatalogService. If I try use busines interface (ITradingStrategyContextRepository - for example) I have error in Crud service implementation: image If I use generic interface I recive a nothe error:

2022-06-06 12:45:53.765 +07:00 [ERR] An exception was thrown while activating Castle.Proxies.TradingStrategyContextCrudAppServiceProxy.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.TradingStrategyContextCrudAppServiceProxy.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.TradingStrategyContextCrudAppServiceProxy' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.Domain.Repositories.IRepository`2[MyExchange.TradingStrategy.TradingStrategyContext,System.Guid] repository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], Volo.Abp.Domain.Repositories.IRepository`2[MyExchange.TradingStrategy.TradingStrategyContext,System.Guid])'.

EugeniZaplatin avatar Jun 06 '22 06:06 EugeniZaplatin

You can of course use a business interface, but you should make the interface Implement IRepository<,> interface.

For example:

ITradingStrategyContextRepository : IRepository<TradingStrategy, Guid>

If I use generic interface I recive a nothe error:

See: https://github.com/abpframework/abp/issues/7068

realLiangshiwei avatar Jun 07 '22 02:06 realLiangshiwei

@realLiangshiwei Thak you

EugeniZaplatin avatar Jun 10 '22 03:06 EugeniZaplatin