我在windsor xml中有以下组件映射:
<component
id="dataSession.DbConnection"
service="System.Data.IDbConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
type="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
lifestyle="custom"
customLifestyleType="MyCompany.Castle.PerOperationLifestyle.PerOperationLifestyleManager, MyCompany.Castle">
<parameters>
<connectionString>server=(local);database=MyCompany;trusted_connection=true;application name=OperationScopeTest;</connectionString>
</parameters>
</component>
<component
id="dataSession.DataContext"
service="System.Data.Linq.DataContext, System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"
type="MyCompany.BusinessLogic.MyCompanyDataContext, MyCompany.BusinessLogic"
lifestyle="custom"
customLifestyleType="MyCompany.Castle.PerOperationLifestyle.PerOperationLifestyleManager, MyCompany.Castle">
<parameters>
<connection>${dataSession.DbConnection}</connection>
</parameters>
</component>
但是,当我要求容器
DataContext
,它实际上使用了需要连接字符串的构造函数,尽管
${dataSession.DbConnection}
作为一个
IDbConnection
.
为什么会这样,以及如何让温莎使用正确的构造器?