Random linq result
I have this LINQ query:
var agnts = (from a in db.agents select new { a.UserId, a.name }).Take(10);
How can I get开发者_StackOverflow 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
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()
精彩评论