Share via


RetrieveByResourcesServiceRequest.Query Field

banner art

Specifies the query for the operation.

Syntax

[Visual Basic .NET]
Public Field Query As QueryBase
[C#]
public QueryBase Query;
[JScript]
public var Query : QueryBase;

Remarks

Assign an instance of the QueryExpression class or QueryByAttribute class. The query must specify the entity name "service" and a columnset. Any other conditions specified will be merged (AND) with those needed to retrieve the resources for the specified service group.

Example

The following code example shows the use of the Query field.

// Set up the CRM service.
CrmService service = new CrmService();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request.
RetrieveByResourcesServiceRequest request = new RetrieveByResourcesServiceRequest();
service sv = new service();

// Create the column set.
ColumnSet colSet = new ColumnSet();
colSet.Attributes = new string[] {"name", "serviceid"};

// Setup the query.
request.Query = new QueryExpression();
request.Query.ColumnSet = colSet;
request.Query.EntityName = "service";

// ResourceIds are the resource GUIDs part of the service. 
request.ResourceIds = new Guid[] {new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3"), new Guid("18ECA720-493E-4800-BBFD-638BD54EB325")};

// Execute the request.
RetrieveByResourcesServiceResponse response = (RetrieveByResourcesServiceResponse)service.Execute(request);

[Visual Basic .NET]
' Set up the CRM service.
Dim service As New CrmService()
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the column set.
Dim cols As New ColumnSet()
cols.Attributes = New String() {"name"}

' Create the request object.
Dim retrieve As New RetrieveByResourcesServiceRequest()

' Set the properties of the request.
retrieve.ColumnSet = cols

' ResourceIds are the resource GUIDs in the service.
retrieve.ResourceIds = {New Guid("2B951FBC-1C56-4430-B23B-20A1349068F3"), New Guid("18ECA720-493E-4800-BBFD-638BD54EB325")}

' Execute the request.
Dim retrieved As RetrieveByResourcesServiceResponse = CType(service.Execute(retrieve), RetrieveByResourcesServiceResponse)

See Also

© 2007 Microsoft Corporation. All rights reserved.