在 Microsoft.Practices.EnterpriseLibrary 中配置连接池

发布于 2024-10-30 21:07:29 字数 761 浏览 0 评论 0原文

我正在使用 Microsoft.Practices.EnterpriseLibrary 中的数据访问应用程序块,并且发现缺少此老化组件的在线文档。

我遇到连接池问题,我想检查/调整它的设置。然而,在连接字符串的配置中似乎没有提到这一点,而这正是我期望配置它的地方。

<connectionString name="Sql Connection String">
    <parameters>
        <parameter name="database" value="DB name" isSensitive="false" />
        <parameter name="password" value="xxx" isSensitive="true" />
        <parameter name="server" value="xxx.xxx.xxx.xxx" isSensitive="false" />
        <parameter name="user id" value="xxxxxxxx" isSensitive="false" />
    </parameters>
</connectionString>

谁能告诉我如何为此组件配置连接池?我在配置文件中配置的是否正确?

我知道有一个与 Microsoft.Practices.EnterprisesLibrary 相关的 Windows 窗体工具,但我无权访问该工具,因此我需要直接配置文件解决方案。

I am using Data Access Application Block from Microsoft.Practices.EnterpriseLibrary and am finding the online documentation for this aging component lacking.

I'm having an issue with connection pooling and I want to review/adjust the settings for it. However, nothing seems to be mentioned about this in the configuration of the connection string, which is where I would expect it to be configured.

<connectionString name="Sql Connection String">
    <parameters>
        <parameter name="database" value="DB name" isSensitive="false" />
        <parameter name="password" value="xxx" isSensitive="true" />
        <parameter name="server" value="xxx.xxx.xxx.xxx" isSensitive="false" />
        <parameter name="user id" value="xxxxxxxx" isSensitive="false" />
    </parameters>
</connectionString>

Can anyone tell me how I configure connection pooling for this component? Am I even right that is configured in the config file?

I know there is a Windows Forms tool available in connection with Microsoft.Practices.EnterprisesLibrary but I don't have access to this, so I need the direct config file solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光下慵懒的猫 2024-11-06 21:07:29

如果您使用基于文件的配置,则 Enterprise Library 使用 connectionStrings 配置部分:

<connectionStrings>

    <add
        name="Sql Connection String" 
        providerName="System.Data.SqlClient"
        connectionString="server=xxx.xxx.xxx.xxx;database=DB name;
Integrated Security=false;User ID=xxxxxxxx;Password=xxx;Pooling=true;
Min Pool Size=5;Max Pool Size=20;" />

</connectionStrings>

如果您使用 流畅配置 它看起来像这样:

var builder = new ConfigurationSourceBuilder();

builder.ConfigureData()
       .ForDatabaseNamed("Sql Database")
         .ThatIs.ASqlDatabase()
         .WithConnectionString("server=xxx.xxx.xxx.xxx;database=DB name;
Integrated Security=false;User ID=xxxxxxxx;Password=xxx;Pooling=true;
Min Pool Size=5;Max Pool Size=20;")
         .AsDefault();

var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current 
  = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

If you are using file based configuration then Enterprise Library uses the connectionStrings configuration section:

<connectionStrings>

    <add
        name="Sql Connection String" 
        providerName="System.Data.SqlClient"
        connectionString="server=xxx.xxx.xxx.xxx;database=DB name;
Integrated Security=false;User ID=xxxxxxxx;Password=xxx;Pooling=true;
Min Pool Size=5;Max Pool Size=20;" />

</connectionStrings>

If you are using fluent configuration it would look something like this:

var builder = new ConfigurationSourceBuilder();

builder.ConfigureData()
       .ForDatabaseNamed("Sql Database")
         .ThatIs.ASqlDatabase()
         .WithConnectionString("server=xxx.xxx.xxx.xxx;database=DB name;
Integrated Security=false;User ID=xxxxxxxx;Password=xxx;Pooling=true;
Min Pool Size=5;Max Pool Size=20;")
         .AsDefault();

var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current 
  = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文