Solved

linq to sql how to get column totals

Posted on 2009-07-15
2
203 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
Comment Utility
try this:
decimal totalPriceSum = (from customers in dc.viewCustomers

                         select customers.totalprice).Sum();

Open in new window

0
 
LVL 12

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
crm development 2 34
Problem to picture file 3 36
Hovering effect 9 28
.Net application crashing 6 19
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now