开发者

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;  
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜