DomainServer use dynamic repository
See original GitHub issueI want to inject dynamic Repository in DomianService, but it didn’t work.
The StockSingleBase.cs and the StockSingleOperationBase.cs are two entities.
IStockSingleManager.cs
public interface IStockSingleManager<TStock,TOperation>: IDomainService where TStock:StockSingleBase where TOperation:StockSingleOperationBase
{
Task GetAsync(Guid cargoid);
}
StockSingleManager.cs
public class StockSingleManager<TStock,TOperation>: DomainService, IStockSingleManager<TStock,TOperation> where TStock:StockSingleBase where TOperation:StockSingleOperationBase,new()
{
private readonly IRepository<TStock, Guid> _stockRepository;
private readonly IRepository<TOperation, Guid> _operationRepository;
public StockSingleManager(IRepository<TStock, Guid> stockRepository, IRepository<TOperation, Guid> operationRepository)
{
_stockRepository = stockRepository;
_operationRepository = operationRepository;
}
public async Task GetAsync(Guid stockId, Guid operationId)
{
var stock = await _stockRepository.GetAsync(stockId);
var operation = await _operationRepository.GetAsync(operationId);
}
}
ToolingSingle.cs
public class ToolingSingle:StockSingleBase
{
public ToolingSingle()
{
}
}
ToolingOperation.cs
public class ToolingOperation:StockSingleOperationBase
{
public ToolingOperation()
{
}
}
IToolingSingleAppService.cs
public interface IToolingSingleAppService: IApplicationService
{
Task<string> TestTask(string aa);
}
ToolingSingleAppService.cs
public class ToolingSingleAppService: ApplicationService,IToolingSingleAppService
{
private readonly IStockSingleManager<ToolingSingle, ToolingOperation> _stockSingleManager;
public ToolingSingleAppService(IStockSingleAppBase<ToolingSingle, ToolingOperation> stockSingleManager)
{
_stockSingleManager = stockSingleManager;
}
public async Task<string> TestTask(string aa)
{
return aa;
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
How can you have a Repository with dynamic data-sources?
Consider implementing special gateway implementation handling access to multiple other gateways (e.g. by looping as you wrote).
Read more >DDD - the rule that Entities can't access Repositories directly
There's a bit of a confusion here. Repositories access aggregate roots. Aggregate roots are entities. The reason for this is separation of ...
Read more >Domain-Driven Design, part 5 — Repository | by Svaťa Šimara
Repositories are persistent collections and allow us to pretend that the system is in-memory. The repository works with complete aggregate and is an...
Read more >Repository Pattern in ASP.NET Core - Ultimate Guide
A Repository pattern is a design pattern that mediates data from and to the Domain and Data Access Layers ( like Entity Framework...
Read more >18 Using Variables in the Oracle BI Repository
You can use variables in a repository to streamline administrative tasks and dynamically modify metadata content to adjust to a changing data environment....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
should this not be
public ToolingSingleAppService(IStockSingleManager<ToolingSingle, ToolingOperation> stockSingleManager)
Also I would investigate whether you can register open generics by convention – not sure on this one!
So
BasicConventionalRegistrar
has the following common implementation for Abp’s conventional dependency registrationsReading here https://github.com/castleproject/Windsor/blob/master/docs/registering-components-by-conventions.md#defaultinterfaces I don’t think that you can register that class by convention this way! Not sure though, give it a test!
Please take a look at the log. Generally in
App_Data/Logs/Logs.txt
.