Use the ColumnSet class

Applies to Dynamics 365 (online), version 9.x

In Dynamics 365 (online) Customer Engagement, 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

Using the QueryExpression Class
Building Queries with QueryExpression
Use the ConditionExpression Class
QueryExpression
ColumnSet