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
Solved

C# - Linq Statement Help

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

828 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