Im tring to make sub-list based on main list with 9 records according to datetime ascending order & then pcName(string).
my sorted sublist need to be like below
ObjectList 1 :
2615,2019-11-22 16:03:22.150,Test1
2615,2019-11-22 16:03:22.200,Test1
2615,2019-11-22 16:03:22.250,Test1
2615,2019-11-22 16:03:22.300,Test1
ObjectList 2 :
2615,2019-11-22 16:03:22.350,Test2
2615,2019-11-22 16:03:22.400,Test2
ObjectList 3 :
2615,2019-11-22 16:03:22.450,Test1
2615,2019-11-22 16:03:22.500,Test1
ObjectList 4 :
2615,2019-11-22 16:03:22.550,Test3
This object list need to take according to sequence ObjectList[0] ,ObjectList[1] ,ObjectList[2] and ObjectList[3]
I mentioned below my sample code
But this only provides me 3 sublist sets(Item1) filter based with Test1, Test2 & Test3 and 9 sublists but i want as above 4 sub lists. where i want to change code ?? Please help me
private void button_Click(object sender, EventArgs e)
{
List<Identity> listOfIdentity = new List<Identity>()
{
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.550"),PcName="Test3"},
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.300"), PcName="Test1"},
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.350"), PcName="Test2"},
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.400"), PcName="Test2"},
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.200"), PcName="Test1"},
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.500"), PcName="Test1"},
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.250"), PcName="Test1"},
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.450"), PcName="Test1"},
new Identity() {id= 2615,QCTime=DateTime.Parse("2019-11-22 16:03:22.150"), PcName="Test1"}
};
List<Identity> sortedIdentity = listOfIdentity.OrderBy(x => x.QCTime).ThenBy(x => x.PcName).ToList(); // here i order by time and then pc name
var items1 = listOfIdentity.OrderBy(x => x.QCTime).ThenBy(x => x.PcName).GroupBy(x => x.PcName).Select(grp => grp.ToList()).ToList(); //sub list create based with **Test1, Test2 & Test3** (3 sub lists)
var items2 = listOfIdentity.OrderBy(x => x.QCTime).ThenBy(x => x.PcName).GroupBy(x => new { x.QCTime, x.PcName }).Select(grp => grp.ToList()).ToList(); //sub list create based with each time and pc name (9 sublists)
}
class Identity
{
public int id { get; set; }
public DateTime QCTime { get; set; }
public string PcName { get; set; }
}