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 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.
VulpesPosted Feb 3, 2014, 11:00 AM
Here's some code:
rahul ahujPosted Feb 3, 2014, 8:54 AM
recordID | TimeIn |TimeOut |BreakFlag | Break
1 | 2014/01/01 9:00:00:00 | 2014/01/01 11:30:05:00 |1 |
2 | 2014/01/01 12:00:00:00| 2014/01/01 16:30:00:00 |1 |
3 | 2014/01/01 16:45:00:00| 2014/01/01 19:30:00:00 |0 |
4 | 2014/01/02 9:00:00:00 | 2014/01/02 12:00:00:00 |1 |
5 | 2014/01/02 12:05:00:00| 2014/01/02 13:00:00:00 |1 |
6 | 2014/01/02 14:00:00:00| 2014/01/02 19:30:00:00 |0 |
I have above data in the list and want to calculate the break time. TimeOut of previous record and TimeIn of next record difference is
time for break.I want to use the LINQ to get following output. It is posible with linq or should i use For loop to get following data
recordID | TimeIn |TimeOut |BreakFlag | Break
1 | 2014/01/01 9:00:00:00 | 2014/01/01 11:30:05:00 |1 | Break 30min
2 | 2014/01/01 12:00:00:00| 2014/01/01 16:30:00:00 |1 | Break 15min
3 | 2014/01/01 16:45:00:00| 2014/01/01 19:30:00:00 |0 |
4 | 2014/01/02 9:00:00:00 | 2014/01/02 12:00:00:00 |1 | Break 5min
5 | 2014/01/02 12:05:00:00| 2014/01/02 13:00:00:00 |1 | Break 60min
6 | 2014/01/02 14:00:00:00| 2014/01/02 19:30:00:00 |0 |
VulpesPosted Jan 31, 2014, 9:27 AM