Given XML like this:

```
<Root>
    <Element>
        <Id>1</Id>
    </Element>
    <Element>
        <Id>2</Id>
    </Element>
    <Element>
        <Id>3</Id>
    </Element>
</Root>

```

And an IEnumerable with this data:

```
[0] = { Id = 1, Data = 429 }
[1] = { Id = 2, Data = 271 }
[2] = { Id = 3, Data = 328 }

```

Is there an elegant way using LINQ to XML to join the IEnumerable data with the XML based on the common `Id` without individually querying for each element to link the data with?

So the result would look like this:

```
<Root>
    <Element>
        <Id>1</Id>
        <Data>429</Data>
    </Element>
    <Element>
        <Id>2</Id>
        <Data>271</Data>
    </Element>
    <Element>
        <Id>3</Id>
        <Data>328</Data>
    </Element>
</Root>

```

The only thing I can come up with is something like this, but I was hoping there was a cleaner method:

```
foreach(var d in MyIEnumerable)
{
    XElement element = (from x in MyXDoc.Elements("Element")
                        where x.Element("Id").Value == d.Id
                        select x).Single();

    element.Add(new XElement("Data", d.Data));
}

```