Bonjour,

Est-ce qu'il y a possibilité d'améliorer les requêtes ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
IEnumerable<XElement> query = from job in xDoc.Descendants("Job")
                              where job.Value.ToUpper().Contains(search.ToUpper())
                              select job;
 
foreach (XElement job in query)
{
    IEnumerable<XElement> query2 = from record in job.Descendants("Record")
                                   where record.Attribute("Identifier") != null
                                   && record.Attribute("Identifier").Value.Equals("ROOT")
                                   select record;
 
    foreach (XElement record in query2)
    {
        IEnumerable<XElement> query3 = from property in record.Descendants("Property")
                                       where property.Attribute("Name") != null
                                       && property.Attribute("Name").Value.Equals("Category")
                                       select property;
 
        foreach (XElement property in query3)
        {
            jobs.Add(property.Value + "\\" + job.Attribute("Identifier").Value);
 
            numberOfResults++;
        }
    }
}
Document XML du style :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
<Root>
    <Job Identifier="NOM">
        <Record Identifier="ROOT">
            <Property Name="Category">\Chemin\...</Property>
            ...
        </Record>
        <Record Identifier="TEST">
            <Property Name="Category">\Chemin\...</Property>
            ...
        </Record>
        ...
    </Job>
    ...
</Root>
Merci.