I have the following code below for a payroll program. The first dictionary contains the identifiers of the employees and the corresponding base payments stored in the master data table. The second dictionary contains the identifiers of employees and the corresponding base payments stored in the table of salary platforms that are used for processing. I want to update the basic salary payments for each employee identifier that does not match in the main table. (Changes in salary).
var OHEMDictionary = employees.OrderBy(es => es.empID) .ToDictionary(od => od.empID, od => od.salary); var SalaryFitmentDictionary = salaryFitments .Where(x => x.U_PD_Code.Trim().ToString() == "SYS001") .OrderBy(es => es.U_Employee_ID) .ToDictionary(od => od.U_Employee_ID, od => od.U_PD_Amount); var difference = OHEMDictionary .Where(kv => SalaryFitmentDictionary[kv.Key] != kv.Value); difference.ToList().ForEach(x => { decimal salary = x.Value.Value; var codeToUpdate = salaryFitments .Where(y => y.U_Employee_ID.Equals(x.Key)) .Select(z => z.Code) .SingleOrDefault(); `**<---exception thrown here**` var salaryFitment = salaryFitmentService .GetSalaryFitment(codeToUpdate); if (salaryFitment != null) {
However, I keep getting the 'Sequence contains more than one element' error. How to solve this error?
source share