---
title: "Use ThenBy()  in Linq Query."  
description: "Use ThenBy()  in Linq Query."  
author: "Norman Reedus"  
published: 2016-03-21  
updated: 2016-03-21  
canonical: https://www.mindstick.com/forum/34070/use-thenby-in-linq-query  
category: "linq"  
tags: ["linq"]  
reading_time: 1 minute  

---

# Use ThenBy()  in Linq Query.

We want to use ThenBy() in [Linq Query](https://www.mindstick.com/forum/33908/how-to-select-and-retrieve-data-using-linq-query-in-entity-framework). How to use this please help me.

## Replies

### Reply by Anonymous User

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Prototype{    class Example    {        static void Main()        {            IList<employee> List = new List<employee>() {             new employee() { id = 1, empname = "John", age = 18 } ,            new employee() { id = 2, empname = "Steve",  age = 15 } ,            new employee() { id = 3, empname = "Bill",  age = 25 } ,            new employee() { id = 4, empname = "Ram" , age = 20 } ,            new employee() { id = 5, empname = "Ron" , age = 19 },             new employee() { id = 6, empname = "Ram" , age = 18 }               };
            var thenByResult = List.OrderBy(s => s.empname).ThenBy(s => s.age);            foreach (employee emp in thenByResult)                Console.WriteLine("Id:" + emp.id + ", Name:" + emp.empname + ", Age:" + emp.age);            Console.ReadLine();        }    }    class employee    {        public int id { get; set; }        public string empname { get; set; }        public int age { get; set; }    }}
```

![Use ThenBy()  in Linq Query.](https://www.mindstick.com/mindstickforums/143bed97-2460-44df-a21d-a686090ea398/images/c25b2609-78fc-4c31-ad57-ad9f1d3cf6f8.png)


---

Original Source: https://www.mindstick.com/forum/34070/use-thenby-in-linq-query

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
