Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

how to query given using LINQ

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
xplode144@gmail.com - 24 Mar 2008 17:37 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.