private async void getChart1() { var list = (List <V_Contractor_noOfWorkorders_workorderType>) await rcs.getV_Contractor_noOfWorkorders_workorderTypeViewsAsync(); if (list.Count > 0) { IsLableVisible = false; IsChartlVisible = true; var groupedList = list.GroupBy(u => u.contractorName) .Select(grp => grp.ToList()) .ToList(); List <V_Contractor_noOfWorkorders_workorderType> twsilats = new List <V_Contractor_noOfWorkorders_workorderType>(); List <V_Contractor_noOfWorkorders_workorderType> projects = new List <V_Contractor_noOfWorkorders_workorderType>(); Contractor_noOfWorkorders_projects = new List <V_Contractor_noOfWorkorders_workorderType>(); Contractor_noOfWorkorders_twsilat = new List <V_Contractor_noOfWorkorders_workorderType>(); foreach (var item in groupedList) { projects.Clear(); twsilats.Clear(); if (item.Count() == 1) { V_Contractor_noOfWorkorders_workorderType tmp = new V_Contractor_noOfWorkorders_workorderType(); if (item.Where(p => p.workorderTypeName == "مشاريع").Count() > 0) { tmp.contractorName = item.First().contractorName; tmp.noOfWorkOrders = 0; tmp.workorderTypeName = "توصيلات"; projects = item.Where(p => p.workorderTypeName == "مشاريع").ToList(); twsilats.Add(tmp); } if (item.Where(p => p.workorderTypeName == "توصيلات").Count() > 0) { tmp.contractorName = item.First().contractorName; tmp.noOfWorkOrders = 0; tmp.workorderTypeName = "مشاريع"; projects.Add(tmp); twsilats = item.Where(p => p.workorderTypeName == "توصيلات").ToList(); } } else { projects = item.Where(p => p.workorderTypeName == "مشاريع").ToList(); twsilats = item.Where(p => p.workorderTypeName == "توصيلات").ToList(); } Contractor_noOfWorkorders_projects.AddRange(projects); Contractor_noOfWorkorders_twsilat.AddRange(twsilats); } } else { IsLableVisible = true; IsChartlVisible = false; } }