Solved

C# - Linq Statement Help

Posted on 2015-02-20
2
47 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

19 Experts available now in Live!

Get 1:1 Help Now