Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have table contain some fields like (EmployeeId + OperationId + Operation_Amount)

I want to get the summation of Operation_Amount for every operation to every employee

Result will be as (EmployeeId + OperationId + Sum_Of_Operation_Amount)

I try use grouping , but I found some rows repeated , then try to use Distinct keyword but also fail

can some one help me pls ...

Imgur: The magic of the Internet[^]

Imgur: The magic of the Internet[^]

Imgur: The magic of the Internet[^]

What I have tried:

C#
var sr = source
    .GroupBy(x => x.OperationId)
    .Distinct()
    .SelectMany(v => v.Distinct())
    .Select(n => new VoucherForPrintSalaryInvoice()
    {
        EmployeeName = n.Employee.EmployeeName,
        OperationName = n.Operation.OperationName.ToString(),
        OperationTypeId = n.Operation.OperationTypeId,
        Amount = _voucherService
            .GeSumOftEmployeeOperations(n.EmployeeId, App.MainCurrency, App.MainCurrency, month, year)

    })
    .Distinct()
    .ToList();
Posted
Updated 13-Mar-20 14:23pm
v6

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900