si2030
asked on
LINQ multiple column grouping
Hi Experts,
I am trying to build a statement where I group on more than one column. I have looked on the web and found this site: http://ddkonline.blogspot.com/2008/04/linq-group-by-syntax-for-grouping-on.html
He supplies this statement in C#:
from f in FundUserRoles
group f by new {f.RoleId, f.UserName}
into myGroup
where myGroup.Count() > 0
select new { myGroup.Key.RoleId, myGroup.Key.UserName, FundCount = myGroup.Count()}
I then tried to make one similar but cannot do it in VB.NET
Dim test = From ledger In db.ledgers _
Group By New {ledger.postingID, ledger.link_posting_id} Into mygroup() Select mygroup.postingId
Wondering if someone might show me the way..
Kind Regards
Simon
I am trying to build a statement where I group on more than one column. I have looked on the web and found this site: http://ddkonline.blogspot.com/2008/04/linq-group-by-syntax-for-grouping-on.html
He supplies this statement in C#:
from f in FundUserRoles
group f by new {f.RoleId, f.UserName}
into myGroup
where myGroup.Count() > 0
select new { myGroup.Key.RoleId, myGroup.Key.UserName, FundCount = myGroup.Count()}
I then tried to make one similar but cannot do it in VB.NET
Dim test = From ledger In db.ledgers _
Group By New {ledger.postingID, ledger.link_posting_id} Into mygroup() Select mygroup.postingId
Wondering if someone might show me the way..
Kind Regards
Simon
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I ended up working this out a different way however the answers above both address the question and thus work...
Dim test = From ledger in db.ledgers _
Group By ledger.postingID, ledger.link_posting_id _
Select ledger.postingID