472,990 Members | 3,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,990 software developers and data experts.

LINQ group

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?
Thanks

Pete
Aug 23 '08 #1
4 1433
This seems very innefficient so there must be a better way of getting a list
of SignalInfo by DisplayPath.

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.Split('/')[2],
Signals = new List<SignalInfo>(from signal in responseData.Signals
where signal.DisplayPath == signalGroup.Key select signal)
};
Pete

Aug 23 '08 #2
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 ?????????????
Try
foreach(SignalInfo signal in signalGroup.Signals)
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 23 '08 #3
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#)
------------------------------------------------------------------------
Aug 24 '08 #4
foreach(IGrouping<string, Signalgroup in signalGroups)
foreach(Signal s in group)
That was exactly the info I needed, thanks very much!

Pete
Aug 24 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David Veeneman | last post by:
I've been hearing a lot about LINQ in connection with Orcas, the next release of VS.NET. Micorosoft touts LINQ as the Next Big Breakthrough, but it looks to me like further muddying of application...
7
by: =?Utf-8?B?Q2hha3JhdmFydGh5?= | last post by:
Today, after watching the presentation by Amanda Silver at http://channel9.msdn.com/Showpost.aspx?postid=335058 , from Channel 9, started exploring the LINQ features. Surprisingly, few facts...
4
by: shapper | last post by:
Hello, I have 2 tables: Aid, Aname ... Bid, Aid, Bname ... I need to get the records in B given a Bname and a Aname. I think I should use Inner Join. I wrote the following code:
8
by: Alcides | last post by:
Hello all, I learn about LINQ here in this forum. I been a VB.NET programmer for quite a while and we are using an internal solution for SQL access. I have some experience with C# and I started...
9
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
Hi all: after reading different places/sites about linq... I ran into these questions: 1. What framework do we need to run linq ? (does it depend on what version of visual studio we have?) how...
3
by: Mike P | last post by:
In this LINQ example, how do you get at the values within the groupings? string anagrams = {"from", "salt", "earn ", "last ", "near ", "form "}; var orderGroups = anagrams.GroupBy( w...
14
by: thj | last post by:
Hi, I was wondering what you guys are using and why? LINQ to SQL or NHibernate? Thanks in advance, Tommy
21
by: hrishy | last post by:
Hi Will LINQ be ported to Python ? regards Hrishy
2
by: shapper | last post by:
Hello, I have the following Linq query: List<PostsTaginsert = (from t in (from t in database.Tags join p in paper.Tags on t.Name equals p.Name select t).ToList() select new PostsTag {
3
by: bob laughland | last post by:
Hi All, I am using a combination of LINQ to SQL and bulk insert. In the process of performing 'one unit of work' I will be doing things like reading, and deleting records using LINQ to SQL and...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.