Randomize OrderBy with EntityDataSource
I am getting a list of people in a EntityDataSource and binding this to a repeater. I want to order them randomly so the people are not always开发者_运维知识库 displayed in the same order. What options do I have to do this?
list.OrderBy(x => Guid.NewGuid())
should do the trick.
Heres the code, for anyone interested.
protected void MyDataSource_QueryCreated(object sender, QueryCreatedEventArgs e)
{
var members = e.Query.Cast<EntityFramework.Member>();
e.Query = from member in members.OrderBy(x => Guid.NewGuid())
select member;
}
精彩评论