DataServiceQuery<TElement>.IncludeTotalCount 메서드
엔터티 집합의 모든 엔터티 수가 쿼리 결과와 함께 인라인으로 반환되도록 요청합니다.
네임스페이스: System.Data.Services.Client
어셈블리: Microsoft.Data.Services.Client(Microsoft.Data.Services.Client.dll)
구문
‘선언
Public Function IncludeTotalCount As DataServiceQuery(Of TElement)
‘사용 방법
Dim instance As DataServiceQuery
Dim returnValue As DataServiceQuery(Of TElement)
returnValue = instance.IncludeTotalCount()
public DataServiceQuery<TElement> IncludeTotalCount()
public:
DataServiceQuery<TElement>^ IncludeTotalCount()
member IncludeTotalCount : unit -> DataServiceQuery<'TElement>
public function IncludeTotalCount() : DataServiceQuery<TElement>
반환 값
유형: System.Data.Services.Client.DataServiceQuery<TElement>
인라인 카운트 옵션이 설정된 새 DataServiceQuery<TElement> 개체입니다.
주의
IncludeTotalCount 메서드 호출은 쿼리 URI에 $inlinecount 쿼리 옵션을 포함하는 것과 같습니다.
예
이 예제에서는 IncludeTotalCount 메서드를 호출한 후에 쿼리를 실행합니다. TotalCount 속성은 쿼리에서 반환하는 엔터티 수를 결정하는 데 사용됩니다.
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)
' Define a new query for Customers that includes the total count.
Dim query As DataServiceQuery(Of Customer) = _
context.Customers.IncludeTotalCount()
Try
' Execute the query for all customers and get the response object.
Dim response As QueryOperationResponse(Of Customer) = _
CType(query.Execute(), QueryOperationResponse(Of Customer))
' Retrieve the total count from the response.
Console.WriteLine("There are a total of {0} customers.", response.TotalCount)
' Enumerate the customers in the response.
For Each customer As Customer In response
Console.WriteLine(vbTab & "Customer Name: {0}", customer.CompanyName)
Next
Catch ex As DataServiceQueryException
Throw New ApplicationException( _
"An error occurred during query execution.", ex)
End Try
// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);
// Define a new query for Customers that includes the total count.
DataServiceQuery<Customer> query = context.Customers.IncludeTotalCount();
try
{
// Execute the query for all customers and get the response object.
QueryOperationResponse<Customer> response =
query.Execute() as QueryOperationResponse<Customer>;
// Retrieve the total count from the response.
Console.WriteLine("There are a total of {0} customers.", response.TotalCount);
// Enumerate the customers in the response.
foreach (Customer customer in response)
{
Console.WriteLine("\tCustomer Name: {0}", customer.CompanyName);
}
}
catch (DataServiceQueryException ex)
{
throw new ApplicationException(
"An error occurred during query execution.", ex);
}