Orderby and thenby using LINQ
<p>I have below table for categories.</p>

<p><strong>tbCategories</strong></p>

<pre><code>CatgID        CatgName
------        --------
  1           Catg1
  2           Catg2
  3           Catg3
  4           Catg4
</code></pre>

<p>Now I have items table which is categorized linking to above categories</p>

<p><strong>tbItem</strong></p>

<pre><code>ItemID            ItemName           ItemCatg         Priority
------            --------           --------         --------
  1                Name 1               1                 1
  2                Name 2               1                 2
  3                Name 3               2                 1
  4                Name 4               3                 3
  5                Name 5               4                 2
  6                Name 6               3                 1
</code></pre>

<p><strong>Priority</strong></p>

<pre><code>1 - High
2 - Medium
3 - Low
</code></pre>

<p>Now when I display the item data, I want the to first display items with category <strong><code>Catg1</code></strong>, <strong><code>Catg2</code></strong> and <strong><code>Catg4</code></strong> based on their priority, then display items with <strong><code>Catg3</code></strong> based on their priority.</p>

<p>I had tried below <code>LINQ</code> expression, but I did not succeed with that. My knowledge on <code>LINQ</code> or <code>SQL</code> is not too strong but that's how much I could reach.</p>

<pre><code>model.items = db.tbItem.OrderBy(p=&gt;p.ItemCatg).ThenBy(p=&gt;p.Priority).ToList();
</code></pre>

<p>Could someone please show me the right way to achieve this functionality?</p>

<p><strong>UPDATE</strong></p>

<p>I would like to achieve below combination while displaying.</p>

<pre><code>ItemID            ItemName           ItemCatg         Priority
------            --------           --------         --------
  1                Name 1               1                 1
  3                Name 3               2                 1
  2                Name 2               1                 2
  5                Name 5               4                 2
  6                Name 6               3                 1
  4                Name 4               3                 3
</code></pre>