try this, check the inline comments
public List GetEmployeMotnhlySalary(decimal Perdaysalary, string sDesignation)
{
getsal obj = new getsal();
{
var EmployeSalarylist = t.Tbl_ResourceTimeSheet.Select(x => new { x.WorkOrderNO, x.Designation, x.ResourceName, x.ResourceID, x.EmployeeID, x.AttendencePeriod, x.NumberofDaysWorked, x.NumberofDaysInMonth, x.Remarks, x.Month, x.Year }).Where(x => x.WorkOrderNO == ddlWorkOrder.Text && x.Month == DLMonth.Text && x.Year == DLYear.Text && x.Designation == sDesignation).ToList();
foreach (var item in EmployeSalarylist)
{
getsal obj = new getsal();
obj.OrderNO = item.WorkOrderNO;
Since
getsal is a
class
which is of
reference type
and the
instance is created once globally outside the loop, so in each iteration of the loop you are just replacing the old values with the new value, at the end of the loop, the last item will be present in all the items of the list..