Random subset of records

Posts   
 
    
siegemos
User
Posts: 47
Joined: 25-Jun-2007
# Posted on: 08-Sep-2009 17:29:51   

Hi all,

I'm trying to get a random selection of records out of a table. I'm trying to do this using maxNumberOfItems set to 5 and a 'random' sort clause:

ISortClause randomClause = new EntityField("NEWID()", new Expression()) | SortOperator.Ascending;

However, when I use that sort clause as an argument in one of the TypedListDAO.GetAsDataReader overloads, the maxNumberOfItems argument gets ignored (no SELECT TOP 5 is generated in the resulting SQL) and returns too many items. When I take the Sort clause out, it works fine, only returning 5 items...

Any ideas?

Thanks.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 08-Sep-2009 21:05:34   

Take a look at the following thread, which address the same issue. http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14174&HighLight=1

Matt