/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { SortProperty sortProperty = gList.SortProperty; int competencyPersonProjectAssessmentId = hfCompetencyPersonProjectAssessmentId.ValueAsInt(); List <CompetencyPersonProjectAssessmentPointOfAssessment> personPointOfAssessmentList = new ResidencyService <CompetencyPersonProjectAssessmentPointOfAssessment>().Queryable() .Where(a => a.CompetencyPersonProjectAssessmentId.Equals(competencyPersonProjectAssessmentId)).ToList(); CompetencyPersonProjectAssessment competencyPersonProjectAssessment = new ResidencyService <CompetencyPersonProjectAssessment>().Get(competencyPersonProjectAssessmentId); List <ProjectPointOfAssessment> projectPointOfAssessmentList; if (competencyPersonProjectAssessment != null) { projectPointOfAssessmentList = new ResidencyService <ProjectPointOfAssessment>().Queryable() .Where(a => a.ProjectId.Equals(competencyPersonProjectAssessment.CompetencyPersonProject.ProjectId)).ToList(); } else { projectPointOfAssessmentList = new List <ProjectPointOfAssessment>(); } foreach (var item in projectPointOfAssessmentList) { if (item.PointOfAssessmentTypeValue != null) { item.PointOfAssessmentTypeValue.LoadAttributes(); } } var joinedItems = from projectPointOfAssessment in projectPointOfAssessmentList join personPointOfAssessment in personPointOfAssessmentList on projectPointOfAssessment.Id equals personPointOfAssessment.ProjectPointOfAssessmentId into groupJoin from qryResult in groupJoin.DefaultIfEmpty() select new { // note: two key fields, since we want to show all the Points of Assessment for this Project, if the person hasn't had a rating on it yet ProjectPointOfAssessmentId = projectPointOfAssessment.Id, CompetencyPersonProjectAssessmentId = competencyPersonProjectAssessmentId, ProjectPointOfAssessmentColor = projectPointOfAssessment.PointOfAssessmentTypeValue != null?projectPointOfAssessment.PointOfAssessmentTypeValue.GetAttributeValue("Color") : string.Empty, ProjectPointOfAssessment = projectPointOfAssessment, CompetencyPersonProjectAssessmentPointOfAssessment = personPointOfAssessmentList.FirstOrDefault(a => a.ProjectPointOfAssessmentId.Equals(projectPointOfAssessment.Id)) }; if (sortProperty != null) { gList.DataSource = joinedItems.AsQueryable().Sort(sortProperty).ToList(); } else { gList.DataSource = joinedItems.OrderBy(s => s.ProjectPointOfAssessment.AssessmentOrder).ToList(); } gList.DataBind(); }