troubleshooting Question

How to do this Linq query with group by?

Avatar of 5281
5281 asked on
C#ASP.NETVisual Basic.NETLINQ Query
5 Comments1 Solution927 ViewsLast Modified:
I put two database tables into two generic class lists.  I want to translate the following sql query into  LINQ Query, but I keep getting errors.

SELECT a.ArticleNumber, a.ArticleType, a.AuthorID, b.AuthorID, b.AuthorName
FROM Article AS a INNER JOIN Author as b ON a.AuthorID=b.AuthorID
WHERE a.ArticleNumber=myNumber
GROUP BY a.ArticleNumber, b.AuthorID, b.AuthorName, a.ArticleType

I tried the following, but there is error for ArticleGroup(), definition of method 'ArticleGroup'  is not accessible in this context.

Dim myNumber as string
Dim ArticleTableList as New List(of clsPaper)     'Class type List holds table Ariticle
Dim AuthorTableList as New List(of clsPeople)  'Class type List holds table Author

Dim CountAritle As clsPaper = (From c In ArticleTableList Join d In AuthorTableList On c.AuthorID Equals d.AuthorID  _
Where c.ArticleNumber = myNumber Group c By c.ArticleNumber, d.AuthorID, d.AuthorName, c.ArticleType _
 Into ArticleGroup() Select c).SingleOrDefault()

I am using ASP.NET in VB.
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros