Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Fordert an, dass die Anzahl aller Entitäten in der Entitätenmenge inline mit den Abfrageergebnissen zurückgegeben wird.
Namespace: System.Data.Services.Client
Assembly: Microsoft.Data.Services.Client (in Microsoft.Data.Services.Client.dll)
Syntax
'Declaration
Public Function IncludeTotalCount As DataServiceQuery(Of TElement)
'Usage
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>
Rückgabewert
Typ: System.Data.Services.Client.DataServiceQuery<TElement>
Ein neues DataServiceQuery<TElement>-Objekt, für das die Inlineanzahloption festgelegt ist.
Hinweise
Das Aufrufen der Methode IncludeTotalCount entspricht dem Aufnehmen der Abfrageoption $inlinecount in den Abfrage-URI.
Beispiele
In diesem Beispiel wird eine Abfrage ausgeführt, nachdem die IncludeTotalCount-Methode aufgerufen wurde. Mit der Eigenschaft TotalCount wird die Anzahl der Entitäten ermittelt, die von der Abfrage zurückgegeben wurde.
' 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);
}