Хотя вы не указали, я думаю, что вы хотите суммировать все данные за один месяц.Таким образом, вместо:
Processor Month Value
1 2018-1 2
1 2018-1 3 => sum all 2018-1 values of processor 1: 2+3=5
1 2018-2 4
1 2018-2 5 => sum all 2018-2 values of processor 1: 4+5=9
2 2018-1 1
2 2018-1 2 => sum all 2018-1 values of processor 2: 1+2=3
Все, что вам нужно сделать, это изменить ResultSelector в вашем GroupJoin, чтобы он группировал все данные в группы с одинаковым [год, месяц].Результатом является [год, месяц, сумма] всех значений с этим годом и месяцем]
См. Одну из перегрузок Enumerable.GroupBy
var result = db.tblProcessorLists.GroupJoin( // GroupJoin processors and transactions
db.tbltransactions,
processor => processor.UserID, // from every processor take the UserId
transaction => transaction.UserID, // from every transaction take the UserId
// ResultSelector: use eacht processor with its zero or more matching transactions
// to make one new object
(processor, transactionsOfThisProcessor) => new
{
Processor = processor,
// group all transactionsOfThisProcessor into groups with same [year, month]
// and sum the values of all transactions in each group
TransactionTotals = transactionsOfThisProcessor
.GroupBy(transaction => new
{
Year = transaction.Year, // KeySelector: make groups with
Month = transaction.Month // same [year, month]
},
// element selector: Transaction.Value
transaction => transaction.Value,
// ResultSelector: key = [year, month],
// elements are all values of this [year, month] group
// sum all values
(key, valuesWithThisYearMonth) => new
{
Year = key.Year,
Month = key.Month,
Total = valuesWithThisYearMonth.Sum(),
}),
});