如何使用 linq 查询从 EntityCollection 中检索信息?

how to retrieve information from EntityCollection using linq queries?

我有一些实体作为

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

来自 retrievedEntities 我想从具有属性值 = 的特定实体检索属性值 = 到某个值(stringint

单个 linq 查询可以解决问题吗??

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

试试@Frebin Francis 的建议

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

我会坚持使用简单明了的 foreach 循环,谢谢

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