DbRangeOptions Enumeration
검색할 인덱스 범위를 지정할 때 SetRange 메서드에서 사용하는 옵션을 지정합니다.
네임스페이스: System.Data.SqlServerCe
어셈블리: System.Data.SqlServerCe(system.data.sqlserverce.dll에 있음)
구문
‘선언
<FlagsAttribute> _
Public Enumeration DbRangeOptions
[FlagsAttribute]
public enum DbRangeOptions
[FlagsAttribute]
public enum class DbRangeOptions
/** @attribute FlagsAttribute() */
public enum DbRangeOptions
FlagsAttribute
public enum DbRangeOptions
멤버
멤버 이름 | 설명 |
---|---|
Default | InclusiveStart 및 InclusiveEnd 플래그를 모두 설정하는 것과 동일합니다. |
ExcludeNulls | 범위에서 null 값을 제외합니다. |
ExclusiveEnd | 범위에서 endData 값을 제외합니다. |
ExclusiveStart | 범위에서 startData 값을 제외합니다. |
InclusiveEnd | 범위에서 endData 값을 포함합니다. |
InclusiveStart | 범위에서 startData 값을 포함합니다. |
Match | startData의 값과 일치하는 인덱스 값의 범위를 지정합니다. Match 옵션을 사용하는 경우 endData는 null로 설정되어야 합니다. |
Prefix | startData의 값에서 시작하는 인덱스 값의 범위를 지정합니다. Prefix 옵션을 사용하는 경우 endData는 null로 설정되어야 합니다. |
주의
Match 또는 Prefix 옵션을 지정할 경우 endData 값은 null이어야 합니다.
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);
}
플랫폼
개발 플랫폼
Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
버전 정보
.NET Framework 및 NET Compact Framework
3.5에서 지원됨
.NET Framework
3.0에서 지원됨
.NET Compact Framework 및 .Net Framework
2.0에서 지원됨