Linq to NHibernate, Order by Rand() ?

Posted by Felipe on Stack Overflow See other posts from Stack Overflow or by Felipe
Published on 2010-05-28T11:40:24Z Indexed on 2010/05/28 11:41 UTC
Read the original article Hit count: 309

Hi everybody, I'm using Linq To Nhibernate, and with a HQL statement I can do something like this:

string hql = "from Entity e order by rand()";

Andi t will be ordered so random, and I'd link to know How can I do the same statement with Linq to Nhibernate ?

I try this:

var result = from e in Session.Linq<Entity> 
             orderby new Random().Next(0,100) 
             select e;

but it throws a exception and doesn't work...

is there any other way or solution?

Thanks

Cheers

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about nhibernate