Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Get Entity by Attribute value from EntityCollection with LINQ

$
0
0

Hello experts,

is there maybe a simple Linq equivalent to that?

Guid incidentid = (Guid)dataReader.GetValue(0); // just to let you know what this variable is

foreach(Entity incident in crmResult.Entities)
{
    if(incident.GetAttributeValue<EntityReference>("incidentid").Id == incidentid)
    {
        //Found! Do stuff here...         
    }
}


What I tried



if(crmResult.Entities.Where(x => x.GetAttributeValue<EntityReference>("incidentid").Id == incidentid))



And


Entity incident = from x in crmResult.Entities
where x.GetAttributeValue<EntityReference>("incidentid").Id == incidentid
select x;


And some other things but my knowledge in linq ends with FirstOrDefault.

Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images