title: C# LinQ Conditional OrderBy
body: <p>so this is my query </p>
  
  <pre><code> var results = tcs.Skip(searchModel.PageSize * (searchModel.Page - 1))
                  .Take(searchModel.PageSize)
                  .AsEnumerable()
                  .Select(x =&gt; new
                  {
                      trackId = x.TrackId,
                      trackName = x.TrackName,
                      category = _weCategoryService.FindAll().Where(y =&gt; y.WorkExperience_Track.TrackId == x.TrackId)
                          .Select(y =&gt; new {
                              categoryId = y.CategoryId,
                              categoryName = y.CategoryName,
                              skill = _skillsService.FindAll().Where(z =&gt; z.CategoryId == y.CategoryId)
                                  .Select(z =&gt; new {
                                      skillId = z.SkillId,
                                      skillName = z.SkillName
                                  }).OrderBy(z =&gt; z.skillName).ToList()
                          }).OrderBy(y =&gt; y.categoryName).ToList()
                  }).OrderBy(x =&gt; x.trackName).ToList();
  </code></pre>
  
  <p>Then i have a model which has a boolean value for <code>SortTrack</code>, <code>SortCategory</code> and <code>SortSkills</code>.
  I want to OrderBy Ascending if the value of the boolean is true and Descending if false.</p>
  
  <p>How to achieve that?</p>