Question

I apologize for my vague question title

I found a code online that suggests a way to create a queryexpression as follows:

 QueryExpression query = new QueryExpression(entity1Name)
    {
        ColumnSet = new ColumnSet(false)
    };

When I tried to do the same in my code, I got an error that the : no constructor exists for QueryExpression that takes 1 argument. However, I can create my queryexpression using this way:

       QueryExpression query = new QueryExpression();
        query.EntityName=entity1Name;
        ColumnSet cset = new ColumnSet();
        cset.AllColumns = false;

This is just an example of many other CRM objects that also behave differently on my side.

Was it helpful?

Solution

QueryExpression class is defined inside the namespace Microsoft.Xrm.Sdk.Query (from Microsoft.Xrm.Sdk.dll) and it has 2 constructors:

public QueryExpression();
public QueryExpression(string entityName);

if you got an error probably you are not referencing the dll included inside the CRM 2011 SDK

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top