DataServiceContext 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 DataServiceContext 서비스의 런타임 컨텍스트를 나타냅니다.
public ref class DataServiceContext
public class DataServiceContext
type DataServiceContext = class
Public Class DataServiceContext
- 상속
-
DataServiceContext
예제
다음 예제에서는 서비스 참조 추가 도구에서 생성된 쿼리를 사용하여 DataServiceContext 모든 고객을 반환하는 Northwind 데이터 서비스에 대해 쿼리를 암시적으로 실행하는 방법을 보여 있습니다. 요청된 Customers 엔터티 집합의 URI는 컨텍스트에 의해 자동으로 결정됩니다. 쿼리는 열거형이 발생할 때 암시적으로 실행됩니다. Northwind 데이터 서비스는 WCF Data Services를 완료할 때 만들어집니다.
// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);
// Define a new query for Customers.
DataServiceQuery<Customer> query = context.Customers;
try
{
// Enumerate over the query result, which is executed implicitly.
foreach (Customer customer in query)
{
Console.WriteLine("Customer Name: {0}", customer.CompanyName);
}
}
catch (DataServiceQueryException ex)
{
throw new ApplicationException(
"An error occurred during query execution.", ex);
}
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)
' Define a new query for Customers.
Dim query As DataServiceQuery(Of Customer) = context.Customers
Try
' Enumerate over the query result, which is executed implicitly.
For Each customer As Customer In query
Console.WriteLine("Customer Name: {0}", customer.CompanyName)
Next
Catch ex As DataServiceQueryException
Throw New ApplicationException(
"An error occurred during query execution.", ex)
End Try
설명
WCF Data Services는 상태 비저장이지만 DataServiceContext 그렇지 않습니다. 클라이언트의 상태는 업데이트 관리와 같은 기능을 지원하기 위해 상호 작용 간에 유지 관리됩니다. 이 클래스와 DataServiceQuery 데이터 서비스에 대한 특정 HTTP 요청을 나타내는 클래스는 클라이언트 라이브러리의 두 가지 기본 클래스입니다.
생성자
| Name | Description |
|---|---|
| DataServiceContext(Uri) |
지정된 클래스를 사용하여 클래스의 DataServiceContext 새 인스턴스를 초기화합니다 |
속성
| Name | Description |
|---|---|
| ApplyingChanges |
현재 추적된 개체에 DataServiceContext 변경 내용을 적용하고 있는지 여부를 나타내는 값을 가져옵니다. |
| BaseUri |
대상 데이터 서비스의 루트를 식별하는 절대 URI를 가져옵니다. |
| Credentials |
개체를 사용하여 DataServiceContext 만든 각 쿼리에서 사용되는 인증 정보를 가져오거나 설정합니다. |
| DataNamespace |
Atom 페이로드의 메타데이터 항목이 아닌 데이터 항목의 XML 네임스페이스를 가져오거나 설정합니다. |
| Entities |
현재 추적 중인 DataServiceContext모든 리소스의 목록을 가져옵니다. |
| IgnoreMissingProperties |
형식에서 읽은 속성을 클라이언트 쪽 형식의 속성에 매핑해야 하는지 여부를 가져오거나 설정합니다. |
| IgnoreResourceNotFoundException |
데이터 서비스에서 404 오류(리소스를 찾을 수 없음)를 반환할 때 예외가 발생하는지 여부를 가져오거나 설정합니다. |
| Links |
개체에서 현재 추적 중인 모든 연결 또는 링크의 DataServiceContext 컬렉션을 가져옵니다. |
| MergeOption |
데이터 서비스에서 엔터티를 수신하기 위한 동기화 옵션을 가져오거나 설정합니다. |
| ResolveName |
데이터 서비스에 엔터티를 보낼 때 클라이언트 라이브러리에서 사용하는 기본 형식 확인 전략을 재정의하는 함수를 가져오거나 설정합니다. |
| ResolveType |
데이터 서비스에서 엔터티를 받을 때 클라이언트 라이브러리에서 사용하는 기본 형식 확인 옵션을 재정의하는 데 사용되는 함수를 가져오거나 설정합니다. |
| SaveChangesDefaultOptions |
메서드에서 SaveChangesOptions 사용되는 SaveChanges() 값을 가져오거나 설정합니다. |
| Timeout |
데이터 서비스에 대한 기본 HTTP 요청에 사용되는 제한 시간 옵션을 가져오거나 설정합니다. |
| TypeScheme |
서비스에서 사용되는 형식 구성표를 나타내는 데 사용되는 URI를 가져오거나 설정합니다. |
| UsePostTunneling |
터널링 후 사용할지 여부를 나타내는 부울 값을 가져오거나 설정합니다. |
메서드
이벤트
| Name | Description |
|---|---|
| ReadingEntity |
엔터티 데이터를 엔터티 개체로 완전히 읽은 후에 발생합니다. |
| SendingRequest |
새로 HttpWebRequest 만들 때 발생합니다. |
| WritingEntity |
엔터티가 요청 메시지에서 XML로 완전히 serialize된 후에 발생합니다. |
적용 대상
추가 정보
WCF Data Services(.NET Framework 클라이언트 라이브러리)