Developer Q&A

Ask a Question
Back to All

Pulling Asset tree by search criteria

Hello Corrigo,

I'm trying to pull the corrigo asset tree by passing in a search criteria a user inputs and I'm noticing the ConditionOperator.Like is not acting how I would expect. I would expect it to be a like search based off the naming. For example I pass in part of a name of an asset, I would expect to get some count back from the AssetTree query. If I put the whole name of the asset in I get the assetTree. Is the ConditionOperator.Like suppose to be a "like" search or is it treated like an equal search?

        var assetTree = new QueryExpression
        {
            EntityType = EntityType.AssetTree,
            PropertySet = new PropertySet
            {
                Properties = new string[]
               {
                    "Id",
                    "ParentId",
                    "ChildId",
                    "Child.*",
                    "Child.Address.*",
                    "Distance"
               }
            },
            Criteria = new FilterExpression
            {

                Conditions = new ConditionExpression[]
               {
                    new ConditionExpression
                    {
                        PropertyName = "Distance",
                        Operator = ConditionOperator.Equal,
                        Values = new object[] {$"{distance}"}
                    },
                    new ConditionExpression
                    {
                        PropertyName = "Child.Name",
                        Operator = ConditionOperator.Like,    <-----------------------
                        Values = new object[] {$"{criteria}"}
                    }
               }
            },
            Orders = new[]
           {
                new OrderExpression
                {
                    PropertyName = "Id",
                    OrderType = OrderType.Ascending
                }
            }
        };

        AssetTree[] results = corrigoService.RetrieveMultiple(assetTree).Cast<AssetTree>().ToArray();