Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 62
  • Last Modified:

C# - Linq Statement Help

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
sbornstein2
Asked:
sbornstein2
1 Solution
 
Lokesh B RDeveloperCommented:
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
 
sbornstein2Author Commented:
tx
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now