Linq to Entities, ordem aleatória
Como devolver entidades correspondentes em uma ordem aleatória?
Para deixar claro, isso é material do Entity Framework e LINQ to Entitie
(código do ar)
IEnumerable<MyEntity> results = from en in context.MyEntity
where en.type == myTypeVar
orderby ?????
select en;
Obrigad
Editar
Tentei adicionar isso ao contexto:
public Guid Random()
{
return new Guid();
}
E usando esta consulta:
IEnumerable<MyEntity> results = from en in context.MyEntity
where en.type == myTypeVar
orderby context.Random()
select en;
Mas eu recebi este erro:
System.NotSupportedException: LINQ to Entities does not recognize the method 'System.Guid Random()' method, and this method cannot be translated into a store expression..
Editar (Código atual):
IEnumerable<MyEntity> results = (from en in context.MyEntity
where en.type == myTypeVar
orderby context.Random()
select en).AsEnumerable();