Peter Morris wrote:
responseData.Signals is a List<SignalInfo>
var signalGroups =
from signal in responseData.Signals
where signal.DisplayPath.StartsWith("AppMenu")
orderby signal.DisplayPath
group signal by signal.DisplayPath into signalGroup
select new { Title = signalGroup.Key, Signals = signalGroup };
foreach(var signalGroup in signalGroups)
foreach(SignalInfo signal in ?????????????
How do I get each SignalInfo in the group?
As Martin said in the other post, simply iterate over teh Signals property.
As you return a new type with just the key and the group, you can also do:
var signalGroups =
from signal in responseData.Signals
where signal.DisplayPath.StartsWith("AppMenu")
orderby signal.DisplayPath
group signal by signal.DisplayPath into signalGroup
select signalGroup;
You can then foreach over the query as:
foreach(IGrouping<string, Signalgroup in signalGroups)
{
// now obtain each signal in the current group
foreach(Signal s in group)
{
}
// the key is obtainable by group.Key
}
FB
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website:
http://www.llblgen.com
My .NET blog:
http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------