Solved

linq to sql how to get column totals

Posted on 2009-07-15
2
206 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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