How do I get a 5 random records from a LINQ to SQL Table[T]?
All the examples I've found via google use uniqueidentifier as the primary key
http://www.davidmuto.com/Blog.muto/View/random-records-with-linq-to-sql
Is there a way to do this when the primary key is an auto-incrementing integer?
Some records can be deleted too, so the min to max ID set will have holes.
Any help is greatly appreciated.
-CV
Best Answer
To start you could take a look at this post which appears to have a way to do what you are seeking: http://weblogs.asp.net/fmarguerie/archive/2008/01/10/randomizing-linq-to-sql-queries.aspx
There is also this post on SO: Random row from Linq to Sql