Use the ColumnSet class

 

Applies To: Dynamics CRM 2013

In Microsoft Dynamics CRM 2013 and Microsoft Dynamics CRM Online, you can use the ColumnSet class to specify what attributes to return from a query expression. The query returns only non-null values.

You can also use the ColumnSet class to reduce the size of a query result by defining only those attributes to be returned. To improve server performance, it is recommended that you don’t execute a query that returns all columns.

The following code example shows how to use the ColumnSet class to specify what attributes to return from a query expression.

QueryExpression contactquery = new QueryExpression
 {
  EntityName="contact",
  ColumnSet = new ColumnSet("firstname", "lastname", "contactid")
 };

See Also

QueryExpression
ColumnSet
Use the QueryExpression class
Build queries with QueryExpression
Use the ConditionExpression class