var query = transactions .GroupBy(t => t.CustomerId) .Select (t => new { Id = t.Key, TranCount = t.Count() }) .ToList();
There is no need to join you, you have all the information about the Transaction object.
However, you need to join if you want to get additional information about the client, such as the name of the client, in which case you could do the following:
var query = (from c in customers join t in transactions on c.ID equals t.CustomerId group c by c.ID into grp select new { Id = grp.Key, Surname = grp.First().Surname, TranCount = grp.Count() }).ToList();
source share