How to pull a RANDOM and UNIQUE record from SQL via LINQ.
Posted
by Jeremy H
on Stack Overflow
See other posts from Stack Overflow
or by Jeremy H
Published on 2010-04-23T16:49:39Z
Indexed on
2010/04/23
16:53 UTC
Read the original article
Hit count: 251
Okay, I found lots of posts on SO about how to pull a RANDOM item from the database when using LINQ. There seems to be a couple of differnet ways to handle this. What I need to do though is pull a RANDOM item from the database that the user has not seen before.
The data I am pulling from the database is very small. Is there any way I can just hit the database once for 1000 records and then randomly scroll through those?
Should I put a cookie on the users system recording the IDs of which items they have seen, pull a random record, check to see if it is seen and if so, pull from the database again? That seems like performance issues just waiting to happen.
I don't expect anyone to code it for me, I am just looking for concepts and pointing in the right direction of how I should go about this.
Need more details? Just let me know!
© Stack Overflow or respective owner