是的,你的抽象业务逻辑应该在一个单独的类库项目中。然后,您可以在同一解决方案中从Web应用程序引用此项目,或者编译它并将其作为DLL引用。您的web.config文件仍将存在于您的Web项目中。
要为您的类库添加设置在你的web项目,使用配置部分:
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="My.Class.Library.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<My.Class.Library.Properties.Settings>
<setting name="SettingName" serializeAs="String">
<value>SettingValue</value>
</setting>
</My.Class.Library.Properties.Settings>
</applicationSettings>
在UI的Web配置中,我应该做些什么改变来从DLL中获取数据而不是实体。目前我的连接字符串看起来像这样 - –
user2215116
@ user2215116据我所知,您的类库应该默认使用web.config文件中的相关连接字符串 –
所以,你的意思是我应该在UI中拥有上面的连接字符串,然后每次将它传递给业务逻辑层,然后通过DLL传递给数据访问层当我想访问数据库(对于每个入口/选择函数)? – user2215116