C# XDocument Attribute Performance Concerns

Posted by Dested on Stack Overflow See other posts from Stack Overflow or by Dested
Published on 2010-03-29T14:51:43Z Indexed on 2010/03/29 14:53 UTC
Read the original article Hit count: 770

Filed under:
|
|
|
|

I have a loaded XDocument that I need to grab all the attributes that equal a certain value and is of a certain element efficiently. My current

            IEnumerable<XElement> vm;
            if (!cacher2.TryGetValue(name,out vm)) { 
                vm = project.Descendants(XName.Get(name));
                cacher2.Add(name, vm);
            }


            XElement[] abdl = (vm.Where(a =>  a.Attribute(attribute).Value == ab)).ToArray();

cacher2 is a Dictionary<string,IEnumerable<XElement>> The ToArray is so I can evaluate the expression now. I dont think this causes any real speed concerns. The problem is the Where itself. I am searching through anywhere from 1 to 10k items.

Any help?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET