Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 143529

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 143529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>