tags:

views:

37

answers:

1

Hello,

I have this LINQ query:

var agnts = (from a in db.agents select new { a.UserId, a.name }).Take(10);

How can I get randomly get 10 records from my agents table?

I have tried:

agnts = agnts.OrderBy(n => Guid.NewGuid());

but this doesn't seem to do anything.

I would appreciate anybody's help on this.

Thanks,

Louis

+1  A: 

Then you do

agnts = agnts.OrderBy(n => Guid.NewGuid());

after

var agnts = (from a in db.agents select new { a.UserId, a.name }).Take(10);

agents are already taken. You need to specify OrderBy() before Take()

valya