一致するエンティティをランダムな順序で返すにはどうすればよいですか?
明確にするために、これはEntity FrameworkのものとLINQ to Entitiesです。
(航空コード)
IEnumerable<MyEntity> results = from en in context.MyEntity
where en.type == myTypeVar
orderby ?????
select en;
ありがとう
編集:
これをコンテキストに追加しようとしました:
public Guid Random()
{
return new Guid();
}
そして、このクエリを使用して:
IEnumerable<MyEntity> results = from en in context.MyEntity
where en.type == myTypeVar
orderby context.Random()
select en;
しかし、私はこのエラーが発生しました:
System.NotSupportedException: LINQ to Entities does not recognize the method 'System.Guid Random()' method, and this method cannot be translated into a store expression..
編集(現在のコード):
IEnumerable<MyEntity> results = (from en in context.MyEntity
where en.type == myTypeVar
orderby context.Random()
select en).AsEnumerable();