3
Answers

Update the list object using linq

rahul ahuj

rahul ahuj

10y
1.7k
1
I have list of object's  and i want to update the the object's Break property where breakflag=1 with its next and previous record.
class EmployeeHour 
{
   int recordID{get;set;}
   string Break{get;set;}
   DateTime TimeIn {get;set;}
   DateTime TimeOut {get;set;}
   int BreakFlag{get;set;}
}
 
List<EmployeeHour> listEH=(from item in employeeHoursList
                      where item.BreakFlag==1     
                        select item).Foreach(itme=>item.Break=(employeeHoursList[i].Timeout-employeeHoursList[i].TimeIn).ToString()).ToList();
 
 
So here i just want set the break property with the Time diff. between TimeIn and  TimeOut only for those objcet whoes breakflag is one. and TimeOut of that object where BeakFlag ==1 and TimeIn next to that object in the list.
 
Thanks
Rahul.
 

Answers (3)