DbConnectionStringBuilder.EquivalentTo(DbConnectionStringBuilder) DbConnectionStringBuilder.EquivalentTo(DbConnectionStringBuilder) DbConnectionStringBuilder.EquivalentTo(DbConnectionStringBuilder) DbConnectionStringBuilder.EquivalentTo(DbConnectionStringBuilder) Method

定義

この DbConnectionStringBuilder オブジェクトの接続情報を、提供されたオブジェクトの接続情報を比較します。Compares the connection information in this DbConnectionStringBuilder object with the connection information in the supplied object.

public:
 virtual bool EquivalentTo(System::Data::Common::DbConnectionStringBuilder ^ connectionStringBuilder);
public virtual bool EquivalentTo (System.Data.Common.DbConnectionStringBuilder connectionStringBuilder);
abstract member EquivalentTo : System.Data.Common.DbConnectionStringBuilder -> bool
override this.EquivalentTo : System.Data.Common.DbConnectionStringBuilder -> bool
Public Overridable Function EquivalentTo (connectionStringBuilder As DbConnectionStringBuilder) As Boolean

パラメーター

戻り値

DbConnectionStringBuilder オブジェクトの両方の接続情報により同等の接続文字列が生じる場合は true。それ以外の場合は falsetrue if the connection information in both of the DbConnectionStringBuilder objects causes an equivalent connection string; otherwise false.

static void Main()
{
    DbConnectionStringBuilder builder1 =
        new DbConnectionStringBuilder();
    builder1.ConnectionString =
        "Value1=SomeValue;Value2=20;Value3=30;Value4=40";
    Console.WriteLine("builder1 = " + builder1.ConnectionString);

    DbConnectionStringBuilder builder2 =
        new DbConnectionStringBuilder();
    builder2.ConnectionString =
        "value2=20;value3=30;VALUE4=40;Value1=SomeValue";
    Console.WriteLine("builder2 = " + builder2.ConnectionString);

    DbConnectionStringBuilder builder3 =
        new DbConnectionStringBuilder();
    builder3.ConnectionString =
        "value2=20;value3=30;VALUE4=40;Value1=SOMEVALUE";
    Console.WriteLine("builder3 = " + builder3.ConnectionString);

    // builder1 and builder2 contain the same
    // keys and values, in different order, and the 
    // keys are not consistently cased. They are equivalent.
    Console.WriteLine("builder1.EquivalentTo(builder2) = " +
        builder1.EquivalentTo(builder2).ToString());

    // builder2 and builder3 contain the same key/value pairs in the 
    // the same order, but the value casing is different, so they're
    // not equivalent.
    Console.WriteLine("builder2.EquivalentTo(builder3) = " +
        builder2.EquivalentTo(builder3).ToString());

    Console.WriteLine("Press Enter to continue.");
    Console.ReadLine();
}
Sub Main()
    Dim builder1 As New DbConnectionStringBuilder
    builder1.ConnectionString = _
        "Value1=SomeValue;Value2=20;Value3=30;Value4=40"
    Console.WriteLine("builder1 = " & builder1.ConnectionString)

    Dim builder2 As New DbConnectionStringBuilder
    builder2.ConnectionString = _
        "value2=20;value3=30;VALUE4=40;Value1=SomeValue"
    Console.WriteLine("builder2 = " & builder2.ConnectionString)

    Dim builder3 As New DbConnectionStringBuilder
    builder3.ConnectionString = _
        "value2=20;value3=30;VALUE4=40;Value1=SOMEVALUE"
    Console.WriteLine("builder3 = " & builder3.ConnectionString)

    ' builder1 and builder2 contain the same
    ' keys and values, in different order, and the 
    ' keys are not consistently cased. They are equivalent.
    Console.WriteLine("builder1.EquivalentTo(builder2) = " & _
        builder1.EquivalentTo(builder2).ToString())

    ' builder2 and builder3 contain the same key/value pairs in the 
    ' the same order, but the value casing is different, so they're
    ' not equivalent.
    Console.WriteLine("builder2.EquivalentTo(builder3) = " & _
        builder2.EquivalentTo(builder3).ToString())

    Console.WriteLine("Press Enter to continue.")
    Console.ReadLine()
End Sub

このサンプルでは、次の出力が表示されます。This sample displays the following output:

builder1 = value1=SomeValue;value2=20;value3=30;value4=40  
builder2 = value2=20;value3=30;value4=40;value1=SomeValue  
builder3 = value2=20;value3=30;value4=40;value1=SOMEVALUE  
builder1.EquivalentTo(builder2) = True  
builder2.EquivalentTo(builder3) = False  

注釈

キー名の比較は大文字小文字を区別します。値の比較は、大文字小文字が区別されます。Comparisons on key names are case insensitive; value comparisons are case sensitive.

EquivalentToメソッドを返します。trueキー/値ペアが等しいか、その順序に関係なく場合。The EquivalentTo method returns true if the key/value pairs are equal, regardless of their order. 2 つの接続文字列の接続の動作は、接続文字列内で順序に意味がないため、それと同等です。The connection behavior of the two connection strings are equivalent, because order is never significant within connection strings. ただし、別の順序には、接続プールのこれらの接続文字列に基づいて接続の動作があります。However, different order may affect connection pooling behavior of connections based on these connection strings.

適用対象

こちらもご覧ください