先说错误:
Configuration is incorrect, the type AccountRepository does not have a constructor that takes parameters named connectionString.
AccountRepository 构造函数代码(此类,仅这一个构造函数):
public AccountRepository(IUnitOfWork unitOfWork, string connectionString) { this.unitOfWork = unitOfWork; this.connectionString = connectionString; }
Unity 配置
<container>
<register type="IUnitOfWork" mapTo="UnitOfWork">
<lifetime type="singleton" />
</register>
<register type="IAccountRepository" mapTo="AccountRepository">
<constructor>
<param name="connectionString" value="Data Source=.;Initial Catalog=Database.WCFData;Integrated Security=SSPI;" />
</constructor>
</register>
</container>
这是什么原因呢? AccountRepository 有两个参数,一个 IUnitOfWork 参数,上面有设置了,仅剩第二个参数连接字符串了,还出个错误~~,求指点,先谢谢。