so this is my query

 var results = tcs.Skip(searchModel.PageSize * (searchModel.Page - 1))
                .Take(searchModel.PageSize)
                .AsEnumerable()
                .Select(x => new
                {
                    trackId = x.TrackId,
                    trackName = x.TrackName,
                    category = _weCategoryService.FindAll().Where(y => y.WorkExperience_Track.TrackId == x.TrackId)
                        .Select(y => new {
                            categoryId = y.CategoryId,
                            categoryName = y.CategoryName,
                            skill = _skillsService.FindAll().Where(z => z.CategoryId == y.CategoryId)
                                .Select(z => new {
                                    skillId = z.SkillId,
                                    skillName = z.SkillName
                                }).OrderBy(z => z.skillName).ToList()
                        }).OrderBy(y => y.categoryName).ToList()
                }).OrderBy(x => x.trackName).ToList();

Then i have a model which has a boolean value for SortTrack, SortCategory and SortSkills. I want to OrderBy Ascending if the value of the boolean is true and Descending if false.

How to achieve that?

Related posts

Recent Viewed