Using Linq, how to separate a list in to grouped objects by name?
Posted
by Dr. Zim
on Stack Overflow
See other posts from Stack Overflow
or by Dr. Zim
Published on 2010-03-30T06:35:39Z
Indexed on
2010/03/30
6:43 UTC
Read the original article
Hit count: 189
I have a table where a record looks like this
varchar(255) Name
varchar(255) Text
varchar(255) Value
Name is the DDL name, Text is what is displayed, and Value is returned upon selection. There are between one and twenty options for each Name. Without iterating though each option like a cursor, is there any way to pull out a list of objects, one for each unique DDL Name, using Linq and C#?
A sample of the data:
Beds '4 (10)' 4
Beds '5 (1)' 5
Beds '7 (1)' 7
Baths 'NA (13)' NULL
Baths '0 (1)' 0
Baths '1 (13)' 1
I was thinking about doing an outer select to get the unique Names, then an inner select to get the list of options for it, then return the set as a List of a set of Lists.
© Stack Overflow or respective owner