在哪里为类库dotnet核心引导IoC

时间:2017-05-13 23:05:22

标签: dependency-injection .net-core ioc-container

我正在使用dotnet core。我正在尝试实现存储库pastern。

我的解决方案按以下方式设置

  1. 网络项目
  2. class library
  3. 的存储库项目

    在我的存储库项目中,我尝试使用Mongo进行所有用户调用。由于class library项目没有像web-project startup.cs这样的入口点。

    我的问题是如何将IMongoClient连接字符串注入存储库类

    对于我的Di我正在使用Structruremap

    例如

    public class UserRepo
    {
    private readonly IMongoClient _client;
    
    UserRepo(IMongClient client)
    {
    _client = client;
    }
    }
    

0 个答案:

没有答案