?
Solved

LINQ to SQL syntax

Posted on 2011-10-25
1
Medium Priority
?
335 Views
Last Modified: 2012-05-12
Can someone show me the LINQ to SQL equivalent  of the following query?

select site, COUNT(site) as Site_count from V_Sites group by site order by Site_count desc

I would like the method that contains the LINQ query to return a value
0
Comment
Question by:wademi
1 Comment
 
LVL 4

Accepted Solution

by:
Gruff82 earned 2000 total points
ID: 37029360
Hi Wademi

you can do what your asking by doing this:

var siteCount = from s in sites 
group s by s.Name into g
select new { Site = g.Key, SiteCount = g.Count() };

Open in new window


This link contains many samples and is a good reference.

MSDN 101 Linq Samples

Thanks Gruff
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question