Random sort list with LINQ and Entity Framework in vb.net
Posted
by Sander Versluys
on Stack Overflow
See other posts from Stack Overflow
or by Sander Versluys
Published on 2010-03-17T15:58:33Z
Indexed on
2010/03/17
16:01 UTC
Read the original article
Hit count: 839
I've seen many examples in LINQ but i'm not able to reproduce the same result in vb.net.
I have following code:
Dim context As New MyModel.Entities()
Dim rnd As New System.Random()
Dim gardens As List(Of Tuin) = (From t In context.Gardens Where _
t.Approved = True And _
Not t.Famous = True _
Order By rnd.Next() _
Select t).ToList()
But i receive an error when binding this list to a control.
LINQ to Entities does not recognize the method 'Int32 Next()' method, and this method cannot be translated into a store expression.
Any suggestion on how to get this to work?
© Stack Overflow or respective owner