S # ARP 아키텍처 쿼리 - 서비스 및 저장소
-
14-09-2020 - |
문제
내 컨트롤러는 리포지토리가 직접 서비스가 아닌 서비스를 사용합니다.서비스는 응용 프로그램 서비스 프로젝트에 있습니다.
public XYZService
(
IBlaRepository BlaRepository,
IBla1Repository Bla1Repository
)
{
Check.Require(BlaRepository != null, "BlaRepository may not be null");
this.BlaRepository = BlaRepository;
....
.
이것은 잘 작동합니다.
리포지토리는 다음과 같이 구현됩니다.
public interface IBlaRepository : IRepository<Bla> (placed in Core/DataInterfaces)
public class BlaRepository : Repository<Bla>, IBlaRepository (placed in Data)
.
때로는 '평범한'날카로운 아키텍처 저장소를 사용할 수 있습니다.위의 서비스로 전달할 수있는 방법이 있습니까?나는 그들을 어딘가에 등록해야합니까?
이를 명확히하기 위해 - 서비스의 개조는 다음과 같이 보입니다 :
public XYZService
(
Repository<UUU> UUURepository
.
...
이것은 이것이 의미가 있습니다.
감사합니다!
크리스
해결책
크리스, 할 필요가있는 모든 것은 저장소를 참조하십시오 :
private readonly IRepository<Bla> _blaRepository;
public BlaService(IRepository<Bla> blaRepository)
{
_blaRepository = blaRepository;
}
.
이렇게하면 윈저가 귀하가 필요없는 다른 것과 함께 컨트롤러에 리포지토리를 주입 할 수 있습니다.
alec
제휴하지 않습니다 StackOverflow