Solved

linq to sql how to get column totals

Posted on 2009-07-15
2
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

617 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