다음을 통해 공유


DbConnectionStringBuilder.EquivalentTo(DbConnectionStringBuilder) 메서드

정의

DbConnectionStringBuilder 개체의 연결 정보를 제공된 개체의 연결 정보와 비교합니다.

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

매개 변수

connectionStringBuilder
DbConnectionStringBuilder

DbConnectionStringBuilder 개체와 비교할 DbConnectionStringBuilder 입니다.

반환

true 개체의 연결 정보가 동일한 연결 문자열을 발생하면 DbConnectionStringBuilder 이고, 그러지 않으면 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

이 샘플은 다음 출력을 표시합니다.

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

설명

키 이름 비교는 대/소문자를 구분하지 않습니다. 값 비교는 대/소문자를 구분합니다.

메서드는 EquivalentTo 키/값 쌍이 순서에 관계없이 같으면 를 반환 true 합니다. 두 연결 문자열의 연결 동작은 동일합니다. 순서는 연결 문자열 내에서 중요하지 않으므로 동일합니다. 그러나 순서가 다르면 이러한 연결 문자열을 기반으로 하는 연결의 연결 풀링 동작에 영향을 줄 수 있습니다.

적용 대상

추가 정보