by ssi
1. May 2013 15:03
private static void Main(string[] args)
{
DataClasses1DataContext dc = new DataClasses1DataContext(DEFAULT_CONNECTION_STRING);
int nMonth = 2;
int nYear = 2013;
for (int index = 0; index < 5; index++)
{
nMonth = index;
Console.WriteLine(string.Format("Month: {0}",nMonth));
var qry = dc.tbl_ssi_LoanSnapshot_Documents.Where(c => c.TakenMonth == nMonth
& c.TakenYear == nYear)
.GroupBy(g => g.DocType)
.Select(g => new
{
DocType = g.Key
,
DocCount = g.Count(p => p.Request_Date != null)
,
DocsReqRecd = g.Count(p => p.Request_Date != null & p.Recieved_Date != null)
,
DocsReqNOTRecd = g.Count(p => p.Request_Date != null & p.Recieved_Date == null)
})
.OrderBy(o => o.DocType);
foreach (var doc in qry)
{
if (doc.DocCount > 100)
Console.WriteLine(string.Format("Month: {0} Doc: {1} Count:{2} ReqRecd: {3} ReqNOTRecd: {4}"
, nMonth , doc.DocType, doc.DocCount, doc.DocsReqRecd, doc.DocsReqNOTRecd));
}
Console.WriteLine("");
}
Console.ReadLine();
}
b5c2fd4b-095c-4abe-b7ce-c4d175f16586|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: LINQ, GroupBy
CSharp