i have a following collection
ReadOnlyDictionary<string, ReadOnlyCollection<DimensionValue>> byVal =
items.ByValues;
which i am looping as follows to obtain the values
foreach (KeyValuePair<string,
ReadOnlyCollection<DimensionValue>> pair in byVal )
{
foreach (Values vals in pair.Value)
{
ddlBrandsList.Items.Add(new ListItem(vals.Name));
}
}
how can i query the collections to obtain the list of vals (values)?
thanks
Jon Skeet [C# MVP] - 24 Mar 2008 18:11 GMT
> i have a following collection
> ReadOnlyDictionary<string, ReadOnlyCollection<DimensionValue>> byVal =
[quoted text clipped - 11 lines]
>
> how can i query the collections to obtain the list of vals (values)?
It's not clear to me exactly what you want the output to be. Could you
give more details, and preferrably some sample data (both input and
desired output)?

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Mark Brackett - 26 Mar 2008 14:48 GMT
>i have a following collection
> ReadOnlyDictionary<string, ReadOnlyCollection<DimensionValue>> byVal =
[quoted text clipped - 13 lines]
>
> thanks
Something like this should work:
ddlBrandsList.Items.AddRange(
from x in byVal
select x.Value.Select(dv => new ListItem(dv.Name)).ToArray()
);
Or, if you'd rather the pure LINQ way:
from x in byVal
select x.Value into vals
from val in vals
select new ListItem(val.Name)
--MB