AVIK DUTTA
AVIK DUTTA

Reputation: 736

how to retrieve information from EntityCollection using linq queries?

I have some entities as

EntityCollection retrievedEntities =(EntityCollection)serviceProxy.RetrieveMultiple(query);

from retrievedEntities i want to retrive a attribute value from a particular entity which has attribule value = to some value(string or int )

Can a single linq query do the trick ??

        var q = from p in retrieve.Entities
                where p.Attributes.Keys = "new_attribute1" && p.Attributes.Values = "avik"
                select p.Attributes.Values;

Upvotes: 0

Views: 6950

Answers (2)

AVIK DUTTA
AVIK DUTTA

Reputation: 736

I will stick with my plain and simple foreach loop thank you

        foreach (var p in retrieve.Entities)
        {
           if(p["new_elementid"]=="some variable or constant ")
               temp = (int)p["new_elementid"];
        }

Upvotes: 0

Vipul Kumar
Vipul Kumar

Reputation: 416

Try this as suggested by @Frebin Francis

var q =retrieve.Entities.Where(x=>x.Attributes.Keys== "new_attribute1" && x.Attributes.Values = "avik").Select(x=>x.Attributes.Values)

Upvotes: 2

Related Questions