title: ASP.NET MVC - How to get random records from model?
body: <p>I don't know if there is an easy way to do it but basically what I would like to do is:</p>
  
  <pre><code>var highlights = db.Banners.Where(h =&gt; h.Category == "highlight").ToList().GetRange(0,4);
  </code></pre>
  
  <p>I have this model Banners where I have some highlights but I would like to retrieve just 4 random highlights each time in different order.</p>
  
  <p>So the code I'm using just retrieve a range from [0..4] highlights and if you have less than 4, it returns an error, and they are not randomised.</p>
  
  <p>Any ideas on how could I do it easily? </p>
  
  <p>The result I would like to have is a <b>List<code>&lt;</code>Banner<code>></code></b> to pass it to the view but each time with different order like:</p>
  
  <pre>[1,3,4,2] || [2,1,4,3] || [12,32,15,3]</pre>
  
  <p>I think that's it :)</p>
  
  <p>Thanks a lot</p>