1

We have CRM 2011 on-premises and I am writing a C# aspx extension program. I need to retrieve a custom entity record by matching on two fields:

1) a lookup to an Entity Reference - I have the Guid of the Entity record. 2) an optionset - I have the text of the optionset.

One than one record might match my criteria; I need the most recent.

How can I do this? Is using LINQ better than QueryExpression or vice versa?

DeveloperM
  • 1,129
  • 7
  • 17
  • 30

1 Answers1

1

I figured it out:

selectedRec = (from raction in context.ce_ractionSet
      where raction.ce_ContractDetailRegarding.Equals(thisGuid) &&
            raction.ce_RActionType.Equals(iRActionTypeValue)
      orderby raction.ModifiedOn descending
      select raction).First();
DeveloperM
  • 1,129
  • 7
  • 17
  • 30