I have two variables Income and Expense, I want to union this two variables and put the result into a sumSalary variable, but I always get an error (the error in sumSalary at Income). Please help me solve this problem.
public void PayrollReport()
{
var income = employeeList.SelectMany(a => a.IncomesModel,(a,b) => new
{
a.Salary,
a.HolidayAllowance,
EmployeeNik = a.NIK,
EmployeeName = a.FirstName,
b.Amount,
b.ModelType,
b.PeriodTime
});
var expense = employeeList.SelectMany(a => a.ExpensesModel, (a, b) => new
{
EmployeeNik = a.NIK,
EmployeeName = a.FirstName,
b.Amount,
b.ModelType
});
var sumSalary = income.Union(expense);
}
Unionto work given the first query returns different columns (e.g. Salary) than the second?