I am trying to convert some of my stored procedures to Linq and am having problems with the following Transact-Sql statement:
Select
Year(p.StartDate) As Year,
(Select Sum(t.Units) From Time t Where Year(t.TransactionDate) = Year(p.StartDate)) As Hours,
(Select Sum(i.Price) From Invoice i Where Year(i.CreatedDate) = Year(p.StartDate)) As Invoices
From
Period p
Group By
Year(p.StartDate)
Order By
Year(p.StartDate)
I'm working with LinqPad to try to figure this out ... any help would be greatly appreciated!
Progress
I have the following so far ... just trying to figure how to convert the sub queries:
from p in Periods
group p by p.StartDate.Year into g
orderby g.Key
select new
{
g.Key,
}