Consider the following XML...

```
<stock>
    <dealer>
        <dealername>Dealer 1</dealername>
        <vehicle>
            <stockID>11111</stockID>
            ...
        </vehicle>
        <vehicle>
            <stockID>22222</stockID>
            ...                
        </vehicle>
        <vehicle>
            <stockID>33333</stockID>
            ...
        </vehicle>
    </dealer>
    <dealer>
        <dealername>Dealer 2</dealername>
        <vehicle>
            <stockID>44444</stockID>
            ...
        </vehicle>
        <vehicle>
            <stockID>55555</stockID>
            ...                
        </vehicle>
    </dealer>
</stock>

```

I need to parse this XML and insert db records containing...

```
Dealer Name
Count of Vehicles for that Dealer Name

```

...so for the above example this would be...

```
DealerName    Count of Vehicles
Dealer 1      3
Dealer 2      2

```

I'm working with the following LINQ code but I can't seem to get the result I need...

```
// count the number of vehicles by dealer name
var qry = from dealer in downloadedXml.Descendants("dealername")
          group dealer by dealer.Value
          into grp
          select new {
             DealerName = grp.Key,
             Count = grp.Select(x => x.Descendants("vehicle")).Distinct().Count()
          };

foreach (var row in qry.OrderBy(x => x.DealerName)) {
    // do db insert
}

```