开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜