Solved

linq to sql how to get column totals

Posted on 2009-07-15
2
207 Views
Last Modified: 2013-11-11
I have created a sql server view and am using linq to sql to read it.

  var testQuery = (from customers in dc.viewCustomers                                    
                                    selectcustomers);

Now the query returns column totalprice that is a money datatype in sql server

I want to amend the query so I get the SUM of totalprice.  
     

These are all
0
Comment
Question by:mugsey
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
GuitarRich earned 500 total points
ID: 24857729
try this:
decimal totalPriceSum = (from customers in dc.viewCustomers
                         select customers.totalprice).Sum();

Open in new window

0
 
LVL 12

Expert Comment

by:GuitarRich
ID: 24857732
this page has loads of good examples that help me with LINQ http://msdn.microsoft.com/en-us/vbasic/bb688085.aspx
0

Featured Post

Independent Software Vendors: 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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 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