Specifies either a QueryExpression or a QueryByAttribute object derived from the QueryBase class. This is the query to be executed for an entity. The QueryExpression or QueryByAttribute object contains the type information for the entity.

[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials
' Create the ColumnSet that indicates the properties to be retrieved.
Dim cols As New ColumnSet()
' Set the properties of the ColumnSet.
cols.Attributes = New String() {"fullname", "contactid"}
' Create the ConditionExpression.
Dim condition As New ConditionExpression()
' Set the condition for the retrieval to be when the contact's address' city is Sammamish.
condition.AttributeName = "address1_city"
condition.Operator = ConditionOperator.Like
condition.Values = New String() {"Sammamish"}
' Create the FilterExpression.
Dim filter As New FilterExpression()
' Set the properties of the filter.
filter.FilterOperator = LogicalOperator.And
filter.Conditions = New ConditionExpression() {condition}
' Create the QueryExpression object.
Dim query As New QueryExpression()
' Set the properties of the QueryExpression object.
query.EntityName = EntityName.contact.ToString()
query.ColumnSet = cols
query.Criteria = filter
' Retrieve the contacts.
Dim contacts As BusinessEntityCollection = service.RetrieveMultiple(query)