This project is read-only.

Using the CrmQuery system in version 1.0

When querying for entities, the CrmQuery class is used. You can chose to specify one condition or several conditions with a logical operator. All examples assume we have a CRM entity classa CrmControllerFactory and a CrmEntityController.

One condition

Find Contacts whose first name is John:

CrmQuery query = new CrmQuery();
query.AddCondition(new CrmAttributeCriterion("firstname", "John", CrmConditionOperator.Equal));
List<CrmContact> contacts = crmContactController.Find(query);

Several conditions

Find Contacts whose first name is John or Jason, or whose last name is Smith:

 

CrmQuery query = new CrmQuery();
query.AddCondition(new CrmAttributeCriterion("firstname", "John", CrmConditionOperator.Equal));
query.AddCondition(new CrmAttributeCriterion("firstname", "Jason", CrmConditionOperator.Equal));
query.AddCondition(new CrmAttributeCriterion("lastname", "Smith", CrmConditionOperator.Equal));
query.LogicalOperator = CrmLogicalOperator.Or;

List<CrmContact> contacts = crmContactController.Find(query);

Note: If you have a query with several conditions, you can only specify one logical operator. This will be improved in the next version.

Last edited Dec 3, 2012 at 2:50 PM by karolikl, version 3

Comments

No comments yet.