我的控制器直接使用服务而不是存储库。服务位于Applicationservices项目中:

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
.

...

希望这是有道理的。

谢谢!

chris

有帮助吗?

解决方案

克里斯, 您需要做的就是指代所在的存储库:

    private readonly IRepository<Bla> _blaRepository; 

    public BlaService(IRepository<Bla> blaRepository) 
    { 
         _blaRepository = blaRepository; 
    }
.

这将允许Windsor将存储库注入到您的控制器中,没有您无需其他要求。

alec

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top