i have a model as below
ID Date BoitierNumber
1 07/04/2012 14:01:46 1
2 07/04/2012 14:01:50 2
3 07/04/2012 14:01:50 3
4 07/04/2012 14:01:56 1
5 07/04/2012 14:02:06 1
6 07/04/2012 14:02:10 2
I have grouped rows by (BoitierNumber)
*boitier Number 1
1 07/04/2012 14:01:46
4 07/04/2012 14:01:56
5 07/04/2012 14:02:06
*boitier Number 2
2 07/04/2012 14:01:50
6 07/04/2012 14:02:10
*boitier Number 3
3 07/04/2012 14:01:50
To do this i have used this code
var groups = context.Essais.GroupBy(p => p.BoitierNumber)
.Select(g => new { GroupName = g.Key, Members = g });
foreach (var g in groups)
{
Console.WriteLine("Members of {0}", g.GroupName);
foreach (var member in g.Members.OrderBy(x=>x.Id))
{
Console.WriteLine("{0} {1}", member.Id,member.Date);
}
}
For the moment everything works fine
now i want to compare the date of two successives grouped rows
if row[i].date>row[i-1].date i will delete row[i-1]
*boitier Number 1
1 07/04/2012 14:01:46
4 07/04/2012 14:01:56
boitier Number 1 ---> Date of row of Id 4 > Date of row of ID 1
then i will delete row of ID 1
Please Help, i don't know how to do this ?
No comments:
Post a Comment