Solved

C# - Linq Statement Help

Posted on 2015-02-20
2
56 Views
Last Modified: 2015-02-23
Anyone have an idea how I can get this data into a LINQ statement example?

SELECT GP.StatusGroupID, GP.StatusGroupName,
       MONTH(IV.PeriodEndDate) PEMonth, YEAR(IV.PeriodEndDate) PEYear,
       COUNT(*) InvCount
 FROM [Customer].[dbo].[invInvoice] IV
 INNER JOIN [Customer].[dbo].[invStatus] ST ON IV.StatusID = ST.StatusID
 INNER JOIN [Customer].[dbo].[invStatusGroup] GP ON ST.StatusGroupID = GP.StatusGroupID
   WHERE
      IV.PeriodEndDate >= DATEADD(MONTH, -11, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)) AND
      IV.PeriodEndDate < DATEADD(MONTH, 1, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0))
GROUP BY GP.StatusGroupID, StatusGroupName, MONTH(IV.PeriodEndDate), YEAR(IV.PeriodEndDate)
ORDER BY PEYear, PEMonth, StatusGroupID
0
Comment
Question by:sbornstein2
2 Comments
 
LVL 14

Accepted Solution

by:
Lokesh B R earned 500 total points
ID: 40625153
var result = (from iv in db.[invInvoice]
             join st in db.[invStatus] on iv.StatusID equals st.StatusID
	     join gp in db.[invStatusGroup] on st.StatusGroupID equals gp.StatusGroupID
	     group iv by new { gp.StatusGroupID, gp.StatusGroupName,
       IV.PeriodEndDate.Month, IV.PeriodEndDate.Year, COUNT(*)} into r
select new
{

  StatusGroupID =  r.Key.StatusGroupID,
StatusGroupName = r.Key.StatusGroupName,
// and so on...


}).ToList();

Open in new window

0
 

Author Closing Comment

by:sbornstein2
ID: 40626737
tx
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

Suggested Solutions

Title # Comments Views Activity
Technology Resume 7 66
Is it possible to preview ajax call before submitting to the database? 18 59
Asp.Net Session Question 2 33
Aspx calendar pop up control 3 25
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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 …

679 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