Retrieve top one record from CRM using early bound

Viewed 2526

I want to retrieve top most record from my CRM entity using early bound query expression.

I have written it as:

QueryExpression opportunityProductsQuery = new QueryExpression
        {
            EntityName = PCSEPortal.oph_ophthalmicclaim.EntityLogicalName,
            ColumnSet = new ColumnSet("Name"),
            Criteria = new FilterExpression
            {
               new ConditionExpression
                        {
                            //condition
                        }
            }
        };
        return "";

But I am not sure how to write where condition and top 1 order by Desc condition here.

For where condition, I have column as Submission channel

- Logical name - oph_submissionchannel
- Schema Name  - oph_SubmissionChannel

and order by Guid or any unique id.

How to write query expression here? Or is there any other better option? I am trying to avoid FetchXML for this.

2 Answers
Related