QueryResult Class

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Message type used to communicate query results between the server and the client.

Inheritance Hierarchy

System.Object
  System.ServiceModel.DomainServices.Client.QueryResult
    System.ServiceModel.DomainServices.Client.QueryResult<T>

Namespace:  System.ServiceModel.DomainServices.Client
Assembly:  System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

Syntax

'Declaration
<DataContractAttribute(Namespace := "DomainServices")> _
Public MustInherit Class QueryResult
'Usage
Dim instance As QueryResult
[DataContractAttribute(Namespace = "DomainServices")]
public abstract class QueryResult
[DataContractAttribute(Namespace = L"DomainServices")]
public ref class QueryResult abstract
[<AbstractClassAttribute>]
[<DataContractAttribute(Namespace = "DomainServices")>]
type QueryResult =  class end
public abstract class QueryResult

The QueryResult type exposes the following members.

Constructors

  Name Description
Protected method QueryResult Initializes a new instance of the QueryResult class.

Top

Properties

  Name Description
Public property TotalCount Gets or sets the total number of rows for the original query without any paging applied to it.

Top

Methods

  Name Description
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetIncludedResults Gets the included results.
Public method GetRootResults Gets the root results.
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)

Top

Examples

Public Function MainPage()
    InitializeComponent()

    ' Create an EntityQuery of type Customer
    Dim query As EntityQuery(Of Customer) = _
        From c In _customerContext.GetCustomersQuery() _
        Where (c.Phone.StartsWith("583")())() _
        Order By (c.LastName) _
        Select c()

    ' Create and execute a LoadOperation of type Customer and load 'query'
    ' LoadBehavior is set to merge this query into the current cache
    Dim loadOp As LoadOperation = Me._customerContext.Load(query, LoadBehavior.MergeIntoCurrent, False)

    ' Create a new DomainOperationException for a Validation Error
    Dim opEx As DomainOperationException = New DomainOperationException( _
                                            "Validation Error", _
                                            OperationErrorStatus.ValidationError, _
                                            9466)
    ' Check if there are any ValidationErrors when loadOp was executed
    ' Then throw the DomainOperationException opEx
    If loadOp.ValidationErrors <> Empty Then
        Throw opEx
    End If

    ' Instantiate a new QueryResult of type Customer
    Dim qr As QueryResult(Of Customer) = New QueryResult(Of Customer)

    ' Populate the CustomerGrid with the QueryResult
    CustomerGrid.ItemsSource = qr.GetIncludedResults
// Create an EntityQuery of type Customer
EntityQuery<Customer> query =
    from c in _customerContext.GetCustomersQuery()
    where c.Phone.StartsWith("583")
    orderby c.LastName
    select c;

// Create and execute a LoadOperation of type Customer and load 'query'
// LoadBehavior is set to merge this query into the current cache
LoadOperation<Customer> loadOp = this._customerContext.Load(query, LoadBehavior.MergeIntoCurrent, false);

// Create a new DomainOperationException for a Validation Error
DomainOperationException opEx = new DomainOperationException(
    "Validation Error",
    OperationErrorStatus.ValidationFailed,
    0x000024FA);

// Check if there are any ValidationErrors when loadOp was executed
// Then throw the DomainOperationException opEx
if (loadOp.ValidationErrors != null)
{
    throw opEx;
}

// Instantiate a new QueryResult of type Customer
QueryResult<Customer> qr = new QueryResult<Customer>();

// Populate the CustomerGrid with the QueryResults
CustomerGrid.ItemsSource = qr.IncludedResults;

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.ServiceModel.DomainServices.Client Namespace