DbRangeOptions 열거형

검색할 인덱스 범위를 지정할 때 SetRange 메서드에서 사용하는 옵션을 지정합니다.

이 열거형에는 해당 멤버 값에 대한 비트 조합이 가능한 FlagsAttribute 특성이 있습니다.

네임스페이스:  System.Data.SqlServerCe
어셈블리:  System.Data.SqlServerCe(System.Data.SqlServerCe.dll)

구문

‘선언
<FlagsAttribute> _
Public Enumeration DbRangeOptions
‘사용 방법
Dim instance As DbRangeOptions
[FlagsAttribute]
public enum DbRangeOptions
[FlagsAttribute]
public enum class DbRangeOptions
[<FlagsAttribute>]
type DbRangeOptions
public enum DbRangeOptions

멤버

멤버 이름 설명
InclusiveStart 범위에 startData 값을 포함합니다.
InclusiveEnd 범위에 endData 값을 포함합니다.
ExclusiveStart 범위에서 startData 값을 제외합니다.
ExclusiveEnd 범위에서 endData 값을 제외합니다.
ExcludeNulls 범위에서 nullnull 참조(Visual Basic에서는 Nothing) 값을 제외합니다.
Prefix startData 의 값에서 시작하는 인덱스 값의 범위를 지정합니다. Prefix 옵션을 사용하는 경우 endData는 nullnull 참조(Visual Basic에서는 Nothing)로 설정되어야 합니다.
Match startData 의 값과 일치하는 인덱스 값의 범위를 지정합니다. Match 옵션을 사용하는 경우 endData는 nullnull 참조(Visual Basic에서는 Nothing)로 설정되어야 합니다.
Default InclusiveStart 및 InclusiveEnd 플래그를 모두 설정하는 것과 동일합니다.

주의

Match 또는 Prefix 옵션을 지정할 경우 endData 값은 nullnull 참조(Visual Basic에서는 Nothing)이어야 합니다.

Match 및 ExcludeNulls 옵션을 함께 사용할 수 없습니다.

이 예제에서 인덱스에 대한 Seek 작업의 범위 옵션은 SetRange 메서드를 호출할 때 InclusiveStart 또는 InclusiveEnd로 지정됩니다.

        Try
            Dim conn As New SqlCeConnection("Data Source = MyDatabase.sdf")
            conn.Open()

            Dim cmd As SqlCeCommand = conn.CreateCommand()
            cmd.CommandType = CommandType.TableDirect
            cmd.IndexName = "Orders_PK"
            cmd.CommandText = "Orders"

            ' We are interested in orders that match Order ID = 10020
            '
            cmd.SetRange(DbRangeOptions.Match, New Object() {10020}, Nothing)

            Dim reader As SqlCeDataReader = cmd.ExecuteReader(CommandBehavior.Default)

            While reader.Read()
                MessageBox.Show(String.Format("{0} ; {1}", reader("Order ID"), reader("Order Date")))
            End While

            ' Now we are interested in orders with Order ID between (10020, 10050)
            '
            cmd.SetRange(DbRangeOptions.InclusiveStart Or DbRangeOptions.InclusiveEnd, New Object() {10020}, New Object() {10050})

            reader = cmd.ExecuteReader(CommandBehavior.Default)

            ' Now seek to Order ID = 10045
            '
            Dim onRow As Boolean =  reader.Seek(DbSeekOptions.FirstEqual, New Object() {10045})

            ' Now ,the reader will return rows with Order ID >= 10045 <= 10050
            ' because the range was set to (10020, 10050)
            '
            If onRow Then
                While reader.Read()
                    MessageBox.Show(String.Format("{0} ; {1}", reader("Order ID"), reader("Order Date")))
                End While
            End If
        Catch e As Exception
            MessageBox.Show(e.Message)
        End Try
        try
        {
            SqlCeConnection conn = new SqlCeConnection("Data Source = MyDatabase.sdf");
            conn.Open();

            SqlCeCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.TableDirect;
            cmd.IndexName = "Orders_PK";
            cmd.CommandText = "Orders";

            // We are interested in orders that match Order ID = 10020
            //
            cmd.SetRange(DbRangeOptions.Match, new object[] { 10020 }, null);

            SqlCeDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);

            for (int i = 1; reader.Read(); i++)
            {
                MessageBox.Show(String.Format("{0} ; {1}", reader["Order ID"], reader["Order Date"]));
            }

            // Now we are interested in orders with Order ID between (10020, 10050)
            //
            cmd.SetRange(DbRangeOptions.InclusiveStart | DbRangeOptions.InclusiveEnd,
                new object[] { 10020 }, new object[] { 10050 });

            reader = cmd.ExecuteReader(CommandBehavior.Default);

            // Now seek to Order ID = 10045
            //
            bool onRow = reader.Seek(DbSeekOptions.FirstEqual, new object[] { 10045 });

            // Now ,the reader will return rows with Order ID >= 10045 <= 10050
            // because the range was set to (10020, 10050)
            //
            if (onRow)
            {
                for (int i = 1; reader.Read(); i++)
                {
                    MessageBox.Show(String.Format("{0} ; {1}", reader["Order ID"], reader["Order Date"]));
                }
            }
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }

참고 항목

참조

System.Data.SqlServerCe 네임스페이스