I need to convert the following TSQL query into a Lambda and am stuck on Count and Sum. I know I can Add .Count() and .Sum at the end of the expression - but how do I get the value as part of the expression?
T-SQL:
select b.pk, b.CreateTime, b.StartTime, b.endTime, count(a.rowid) as total,
sum(case when ItemStatus = 'success' then 1 else 0 end) as Sucess from... group by...
My expression thus far:
var results = from context1 in dmbl1 join context2 in dmbl2 on context1.BatchLog_ID equals context2.pk
select new
{
CycleID = context2.pk,
CreateDateTime = context2.CreateDateTime,
StartTime = context2.startTime,
endTime = context2.endTime,
total = context1.RowID. <<<<< This is where I need Countof
Success = <<< This is where I need Sumof
};