title: Convert Sql Query To linq using sum with group by
body: <p>I am new to linq can any body please help me out to convert following query to linq.</p>
  
  <pre><code>   SELECT A.Name,
     Sum(C.MoneyIN) - Sum(C.MoneyOut) AS Balance
     FROM   Customers A
     JOIN   Banks B ON A.Id = B.id
     JOIN   BankTransactions C ON B.Id = C.BankID
     GROUP  BY A.Name
  </code></pre>
  
  <p>I tried to convert it into linq</p>
  
  <pre><code>var query =  from c in db.Customers
                       join b in db.Banks on c.Id equals b.CustomerId
                       join bt in db.BankTransactions on b.Id equals bt.BankId                         
                       group c by c.Name into Cust                         
                       select new
                       {
                           Name = c.Name,
                           Balance = Cust.Sum(bt.MoneyIn) - Cust.Sum(bt.MoneyOut) 
                       };
  </code></pre>
  
  <p>Can anybody please tell me where I am wrong ?</p>
  
  <p>Thanks in advance.</p>