locked
Why i can't filters using query expression RRS feed

  • Question

  • User-893002196 posted

    Hi All,

    I have

    public static List<Guid> RetrieveType(CrmService crmService, List<object> Roles)
            {
                QueryExpression query = new QueryExpression();
                query.EntityName = EntityName.customertype.ToString();
    
               
                // Retrieve the accounts where the last name is not Cannon.
                ConditionExpression condition = new ConditionExpression();
                condition.AttributeName = "name";
                condition.Operator = ConditionOperator.In;
                condition.Values = new object[] { Roles.Cast<object>().ToArray() };
    
                // Build the filter based on the condition.
                FilterExpression filter = new FilterExpression();
                filter.FilterOperator = LogicalOperator.And;
                filter.Conditions = new ConditionExpression[] { condition };
    
                // Set the Criteria property.
                query.Criteria = filter;
    
                ColumnSet cols = new ColumnSet();
                cols.Attributes = new string[] { "customertypeid", "name" };
                query.ColumnSet = cols;
    
    
    
                BusinessEntityCollection bec = crmService.RetrieveMultiple(query);
                List<Guid> d = new List<Guid>();

    If i change this line code as bold above condition.Values = new object[] { Roles.Cast<object>().ToArray() };  to be

    condition.Values = new String[] { "JUB","SUB" };   It's work fine.

    How can i make this line of code work condition.Values = new object[] { Roles.Cast<object>().ToArray() }; ????

    Please advise.

    Thank you.

    Regards,

    Micheale

    Thursday, June 12, 2014 10:29 PM

Answers

  • User-893002196 posted

    Solved!

    Solution:-

    condition.Values = Roles.Cast<object>().ToArray();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 16, 2014 9:01 PM